Apply background image to AlertDilog
I want to display a menu in a different style for that开发者_开发知识库 I want give background image to alertdialog
.
Any tutorial or link which help me to achieve my goal.
well, you can create an AlertDialog within a custom view, in that custom view only assign a background you want. Later set that view like AlertDialog custom view. an example: - A 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>
now, inflate this view and set like dialog custom view
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();
}
hope this helps
精彩评论