对话框中的多个 EditText
Multiple EditText in Dialog
好的,嗨!
几个小时以来,我一直在尝试将我的对话框设置为具有不止一个或两个可编辑的 EditText。
EditTexts 在 Dialog 的 space 上可见,但是当我想编辑其中任何一个的内容并点击它时,这个魔术键盘没有出现。
public class Statistics extends ActionBarActivity{
.
.
.
public void buttonClick(View view) {
Random r = new Random();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.intintmap_item_list);
int temp = r.nextInt(6);
for(int i = 0; i < temp; i++){
adapter.add("data"+i);
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("title");
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
}
});
builder
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Log.d("AAAAAA", "YES");
}
})
.setNegativeButton("NO!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Log.d("AAAAAA","NO");
}
});
AlertDialog alert = builder.create();
alert.show();
}
intintmap_item_list.xml
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="number"
android:ems="10"
android:id="@+id/intintmapitemlist"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
任何人都可以帮忙吗?请?
将此粘贴到 buttonClick 方法的末尾有帮助:
alert.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
好的,嗨! 几个小时以来,我一直在尝试将我的对话框设置为具有不止一个或两个可编辑的 EditText。 EditTexts 在 Dialog 的 space 上可见,但是当我想编辑其中任何一个的内容并点击它时,这个魔术键盘没有出现。
public class Statistics extends ActionBarActivity{
.
.
.
public void buttonClick(View view) {
Random r = new Random();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.intintmap_item_list);
int temp = r.nextInt(6);
for(int i = 0; i < temp; i++){
adapter.add("data"+i);
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("title");
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
}
});
builder
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Log.d("AAAAAA", "YES");
}
})
.setNegativeButton("NO!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Log.d("AAAAAA","NO");
}
});
AlertDialog alert = builder.create();
alert.show();
}
intintmap_item_list.xml
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="number"
android:ems="10"
android:id="@+id/intintmapitemlist"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
任何人都可以帮忙吗?请?
将此粘贴到 buttonClick 方法的末尾有帮助:
alert.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);