如何实现自定义AlertDialog视图
如果要显示更复杂的视图,请查找称为“body”的FrameLayout,并将视图添加到其中:
FrameLayout fl = (FrameLayout) findViewById(R.id.body);fl.add(myView, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
add()
addView()
.
setView(findViewById(R.layout.whatever)
AlertDialog.Builder builder = new AlertDialog.Builder(this);builder.setTitle("Title") .setCancelable(false) .setPositiveButton("Go", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { EditText textBox = (EditText) findViewById(R.id.textbox); doStuff(); }});FrameLayout f1 = (FrameLayout)findViewById(R.id.body /*CURRENTLY an ERROR*/);f1.addView(findViewById(R.layout.dialog_view));AlertDialog alert = builder.create();alert.show();
慕村225694
相关分类