abd*_*him 5 android android-alertdialog
当我将 setItems 与自定义布局一起使用时,我的布局显示在项目按钮(由 setItems 创建)下方。
有什么方法可以在顶部显示自定义布局,然后显示项目按钮?或者我需要在自定义布局中添加项目按钮?
AlertDialog.Builder myDialog = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.alert_dialog_addons, null);
myDialog.setTitle(title);
myDialog.setView(layout); // WANT TO SHOW THIS ON TOP
//THEN THIS
myDialog.setItems(options, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//DO SOMTHING
}
});
myDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
myDialog.create().show();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
972 次 |
| 最近记录: |