我想以不同的样式显示菜单,因此我想给
有没有任何教程或链接可以帮助我实现我的目标?
alertdialog
设置背景图像。有没有任何教程或链接可以帮助我实现我的目标?
alertdialog
设置背景图像。好的,您可以在自定义视图中创建AlertDialog,在该自定义视图中仅分配所需的背景。然后将该视图设置为AlertDialog自定义视图。 例如: - 一个RelativeCustomLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/shape_1"
android:padding="10dip">
............
</RelativeLayout>
现在,将此视图展开并设置为对话框自定义视图
protected void createCustomDialog(int drawable, String title, String message){
LayoutInflater inflater = LayoutInflater.from(WkActivity.this);
View customDialog = inflater.inflate(R.layout.generic_error_dialog, null);
((TextView)customDialog.findViewById(R.id.genericErrorDialogTitle)).setText(title);
((TextView)customDialog.findViewById(R.id.genericErrorDialogMessage)).setText(message);
((ImageView)customDialog.findViewById(R.id.genericErrorDialogIcon)).setImageResource(drawable);
dialog = new AlertDialog.Builder(WkActivity.this).create();
dialog.setView(customDialog);
dialog.setButton(getText(R.string.listaBusquedasGuardadasNoResultDialogButton), onClickListener);
dialog.show();
}