1
我在xml布局中有一个EditText字段,我将该xml设置为对话框的布局。当我点击EditText字段时,它没有显示任何回应。键盘不显示,光标不显示。这里是dialog_layout.xmlEditText字段没有输入
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ADD"
android:id="@+id/buttonDialog"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_above="@+id/buttonDialog"
android:layout_centerHorizontal="true">
<requestFocus />
</EditText>
</RelativeLayout>
这里是Java代码:
AddBody.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
final Dialog dialog = new Dialog(getApplicationContext());
dialog.setContentView(R.layout.dialog_layout);
dialog.show();
/*rest of the code*/
什么是addbody? – XxGoliathusxX
这是一个按钮。对话框应该在用户点击时打开 –