我有一个自定义对话框,我将其设置为一个函数:
public void customDialog(Bitmap bm,String title){
TextView dialogtext = (TextView)findViewById(R.id.layout_root);
//For above also tried r.id.popup which is the containing file for the layout
ImageView dialogimage = (ImageView)findViewById(R.id.popupimage);
dialogtext.setText(title);
dialogimage.setImageBitmap(bm);
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.popup,(ViewGroup) findViewById(R.id.layout_root));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.show();
}
每当我尝试使用Null指针异常动态设置XML字段时,对话框都会失败.我很难过,有什么想法吗?我是否必须在清单中添加一些自定义对话框?