Android:以编程方式将ListView设置为Dialog内容
|
我究竟做错了什么?我收到一个没有内容的空白对话框。码:
@Override
protected Dialog onCreateDialog(int id, Bundle b) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
switch(id) {
case DIALOG_COLOR_MODE:
{
LinearLayout layout = new LinearLayout(this);
LinearLayout.LayoutParams lllp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(lllp);
ListView modeList = new ListView(this);
Dialog dialog = new Dialog(this);
TextView layoutBright = new TextView(this);
TextView layoutNormal = new TextView(this);
layoutBright.setText(\"Bright Mode\");
layoutNormal.setText(\"Normal Mode\");
modeList.addFooterView(layoutBright);
modeList.addFooterView(layoutNormal);
layout.addView(modeList);
dialog.setContentView(layout);
return dialog;
}
[...]
没有找到相关结果
已邀请:
1 个回复
森含械
但是说实话,使用AlertDialog.Builder.setItems()是一个更好的解决方案。