Android 实现多个输入框的对话框
来源:互联网 发布:java.io.file jar包 编辑:程序博客网 时间:2024/04/27 23:33
先看一下效果吧:
布局文件:dialog.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:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="@string/inownername" /> <EditText android:id="@+id/ownername" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_marginRight="20dp" android:ems="10"> <requestFocus /> </EditText> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="@string/inownerphone" /> <EditText android:id="@+id/ownerphone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_marginRight="20dp" android:ems="10" /></LinearLayout>
调用的方法:
protected void showAddDialog() {LayoutInflater factory = LayoutInflater.from(this);final View textEntryView = factory.inflate(R.layout.dialog, null);final EditText editTextName = (EditText) textEntryView.findViewById(R.id.ownername);final EditText editTextNumEditText = (EditText) textEntryView.findViewById(R.id.ownerphone);AlertDialog.Builder ad1 = new AlertDialog.Builder(LoginActivity.this);ad1.setTitle("添加业主信息:");ad1.setIcon(android.R.drawable.ic_dialog_info);ad1.setView(textEntryView);ad1.setPositiveButton("确定", new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int i) {Log.i("111111", editTextName.getText().toString());Owner person = new Owner();person.setOwnername(editTextName.getText().toString());person.setOwnerphone(editTextNumEditText.getText().toString());}});ad1.setNegativeButton("取消", new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int i) {}});ad1.show();// 显示对话框}
怎么样,是不是非常简单啊,呵呵.
0 0
- Android 实现多个输入框的对话框
- Android 实现多个输入框的对话框
- Android 实现多个输入框的对话框
- Android 实现多个输入框的对话框
- Android 实现多个输入框的对话框
- Android基础控件——AlertDialog、ProgressDialog实现单选对话框、多选对话框、进度条对话框、输入框对话框
- 实现多个输入框的dialog
- android 弹出带输入框的对话框
- android 弹出带输入框的对话框
- android 弹出带输入框的对话框
- Android弹出的对话框显示输入框
- 各种对话框的实现(文字对话框,选择对话框,弹出输入对话框,单选,多选对话框,自定义对话框)
- android自定义普通对话框,输入框对话框
- Android:创建能输入内容的常见对话框以及使用对话框实现逻辑处理
- Android对话框显示输入框
- Android对话框的实现
- Android Dialog(对话框中获取输入框的内容)
- 多个Eidtview连续输入的实现
- [Unity3D]网游中实现资源动态加载 。。手游消减内存必备。。。
- html5的自定义data-*属性与jquery的data()方法的使用
- 【HDU 4921】Map
- Hadoop中解决跨split问题
- IOS用openurl打开设置选项 ===== 有的可能已被苹果官方禁用
- Android 实现多个输入框的对话框
- 约瑟夫环问题的详细解答
- linux oops产生过程之dump_backtrace
- 修改主机名
- 统计难题 (字典树)
- android webview的jsinterface有时候不被识别的原因
- IE6,IE7,IE8下报JS错误:expected identifier, string or number的原因及解决办法
- 使用RAII技术来管理资源
- Android-通讯录:添加联系人