1
我在做什麼錯?我收到一個沒有內容的空白對話框。代碼:Android:以編程方式將ListView設置爲對話內容
@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;
}
[...]