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
這是一個按鈕。對話框應該在用戶點擊時打開 –