2
@Override
protected Dialog onCreateDialog(int id) {
    // TODO Auto-generated method stub
    if(id == 0){
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);

    dialog.setTitle("page");
    dialog.setIcon(R.drawable.icon);

        return dialog.create();
    }else{
     return super.onCreateDialog(id);
    }
}

使用 onCreateDialog 创建对话框

 @Override
protected void onPrepareDialog(int id, Dialog dialog) {
    // TODO Auto-generated method stub
    super.onPrepareDialog(id, dialog);

      LayoutInflater vi = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
    if(id==0){

        View lo = (LinearLayout)vi.inflate(R.layout.detail_dialog, null);

                   ~~inflate View~~

        ((AlertDialog) dialog).setView(lo);
    }
}

但是Dialog没有设置View。并且不要更改对话框。

如何在对话框中绘制不断变化的内容视图?

4

0 回答 0