Search code examples
androidandroid-alertdialogandroid-dialogfragmentandroid-dialog

How to set drawables for buttons in an alert dialog? in Android


I want to set an Image and two buttons in an alert dialog ,i have tried the below code,i can set the image ,but i don't know how to set icon's for buttons.And i also want to align first button on the bottom of another button like this screen shot.

I have tried this code to add an image

 public void showAlert()
 {
AlertDialog.Builder alertadd = new AlertDialog.Builder(
        MainActivity.this);

LayoutInflater factory = LayoutInflater.from(MainActivity.this);
final View view = factory.inflate(R.layout.alertimage, null);
alertadd.setView(view);
alertadd.setNeutralButton("Here!", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dlg, int sumthin) {

    }
});

alertadd.show();
}

Solution

  • I have solved the problem using a simple Popup window.It works fine.