erp*_*erp 3 android android-layout android-alertdialog
如果它有两个 textEdit,则处理一个对话框以在其中弹出该对话框。我想从提交时的文本编辑中获取信息,但不知道如何。我也不知道如何为普通对话框执行提交或取消按钮(我知道您可以在带有“setNegativeButton”的 alertDialog 上)。
那么如何向常规对话框添加提交或取消?到目前为止,这就是我正在使用的:
public void changeEmail(View v){
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.change_email_dialog);
dialog.setTitle("Enter your new email");
dialog.show();
}
Run Code Online (Sandbox Code Playgroud)
我想我也想知道是否有人可以快速解释我如何从对话框使用的布局内的两个文本编辑中获取信息?
小智 5
创建布局文件:custom.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF" />
<TextView
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
单击按钮时创建以下 onClick 函数(当您希望出现对话框时):
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Title");
// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.text1);
text.setText("Text view 1");
TextView text = (TextView) dialog.findViewById(R.id.text2);
text.setText("Text view 2");
dialog.show();
}
});
Run Code Online (Sandbox Code Playgroud)
这是教程的链接,可准确获取您想要的内容。
这是一个关于 Stack Overflow 的问题的链接,它提供了有关自定义对话框的信息。
| 归档时间: |
|
| 查看次数: |
16094 次 |
| 最近记录: |