登入对话框
来源:互联网 发布:如何用淘宝联盟返利 编辑:程序博客网 时间:2024/06/11 01:52
/*
* 登入对话框
* 在xml文件里我们定义了三个输入框,一个是用户名输入框、
* 一个是密码输入框另一个是电话号码输入框,下面我们就在
* 应用程序中调用AlertDialog.Builder的setView(View view)
* 方法让对话框显示该输入界面
*/
import 略
public class Ex02_11Activity extends Activity {private Button bt;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);bt = (Button) findViewById(R.id.bt);final Builder builder = new AlertDialog.Builder(this);bt.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stuTableLayout loginForm = (TableLayout) getLayoutInflater().inflate(R.layout.loginlayout, null);// 设置对话框图标和标题builder.setIcon(R.drawable.tools).setTitle("自定义对话框").setView(loginForm)//这里是为对话框添加布局文件.setPositiveButton("登入", new OnClickListener() {public void onClick(DialogInterface dialog,int which) {// TODO Auto-generated method stub// 此处填写点 击登 入按钮后处理的事件}}).setNeutralButton("取消",new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog,int which) {// TODO Auto-generated method stub// 此处填写点击 取消 按钮后处理的事件}}).show();}});}}
下面我们就来看看两个布局文件main.xml和loginlayout.xml。
main.xml文件其实很简单:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:gravity="center_horizontal|center" android:text="@string/hello" android:textSize="20dp" /> <Button android:id="@+id/bt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="20dp" android:text="@string/regist" /></LinearLayout>
loginlayout.xml文件code
<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/loginForm" android:layout_width="match_parent" android:layout_height="wrap_content" > <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/username" /> <!-- 输入用户名文本框 --> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/hintUser" android:selectAllOnFocus="true" /> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/username" /> <!-- 输入密码文本框 --> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/hintPwd" android:inputType="textPassword" /> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/phone" /> <!-- 输入电话号码文本框 --> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="phone" android:selectAllOnFocus="true" /> </TableRow></TableLayout>
下面我们来看下程序运行后的效果:
完..............................................
- 登入对话框
- 人员登入2 ---登入页面
- 人员登入5---实现登入
- fedora12 root 登入
- Linux单用户登入
- Mysql 登入
- 远程登入mysql
- adminstrator 登入
- 单点登入技术
- 应用程序第一次登入
- 登入Linux主机
- ubuntu root登入
- curl模拟登入
- 单点登入配置
- 远程登入mysql
- 登入编程码
- 单点登入登出
- 检测手机登入
- 百度最新面试题集锦
- 修改UISearchBar放大镜图片(_searchBar._searchField.leftView)
- 模体发现问题
- CString常用方法简介
- POJ 2407 Relatives 欧拉函数(简单求函数值)
- 登入对话框
- AJAX异步回发事件
- ibatis调用存储过程:返回NUMBER,对应java类型的解决办法
- C语言实现的 itoa(int num, str *temp, int radix) 与 atoi(str *temp)
- 计算机组织与设计之读书笔记
- linux 版本中 i386/i686/x86-64/pcc 的区别
- 投资提醒金句
- NBA球星来华 打短工还是掠夺性开发?
- v1