2012-03-05 76 views

回答

2

当然,您可以使用Dialog.setContentView()将对话框的内容设置为任意布局。

Dialog dialog = new Dialog(this); 
dialog.setContentView(R.layout.yourLayoutId); 
dialog.show(); 

让自己与你想在它和调用的setContentView您的对话框上的一个组件的布局文件,通过你的布局文件的名称。

如果你是deadset上AlertDialog你可以用builder.setView()类似

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot)); 
AlertDialog.Builder builder = new AlertDialog.Builder(this) 
.setView(layout); 
AlertDialog alertDialog = builder.create(); 
alertDialog.show(); 
+0

伟大它的作品,我可以给+1只:( – Jaguar 2012-12-13 13:14:43

+0

谢谢@Jaguar – 2012-12-15 06:10:32

+0

的问题是关于多选择的部分比布局多,我现在正在寻找同样的东西...... – DoruChidean 2015-07-09 16:00:26

相关问题