我有一個對話窗口,如圖所示,並且我有要求在每個項目旁邊添加一個EditText(取數量),任何可能的方法來實現此目的...?將EditText添加到對話框
我試圖創建獨立的觀點,並將其設置爲AlertDialog,但得到的底部單一的EditText ..
有沒有辦法,我可以在清單中添加的EditText旁邊的每一個項目的任何可能的方式這裏BEC項目是從一個一個數組項[]填充,用
DialogInterface.OnMultiChoiceClickListener itemsDialogListener =
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if(isChecked)
selectedItems.add(Items[which]);
else
selectedItems.remove(Items[which]);
StringBuilder stringBuilder = new StringBuilder();
for(CharSequence item : selectedItems)
stringBuilder.append(item + ",");
selectItems.setText(stringBuilder.toString());
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater li=LayoutInflater.from(this);
View v1=li.inflate(R.layout.itementry, null);//itementry view has one EditText
builder.setTitle("Select Items");
builder.setMultiChoiceItems(colours, checkedItems, itemsDialogListener);
builder.setView(v1); //By setting this line only one EditText is visible at
the bottom of alert dialog.
AlertDialog dialog = builder.create();
dialog.show();
我想這應該是的setView(R.layout.layoutDialog) ; – 2011-12-22 06:00:13
@ N-JOY選中此[Android自定義對話框](http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog)並搜索setContentView()。 – 2011-12-22 06:03:58
你okk我以爲你提醒它alertDialog。因爲AlertDialog.Builder類具有方法setView(layout); – 2011-12-22 06:09:56