Reputation: 1155
I am making one custom alertdialog having ONE image. The problems I am facing are as follows:
1) For devices with small screen this alertdialog box appears to be too big. the aletdialog buttons are going out of screen( positive and negative buttons).
2) The alertdialog is getting drawn twice. ie there are 2 alertdialogs one over the other and i have to click the positive button twice to close both of them.
Here is the code for alertdialog:-
AlertDialog.Builder alertdialog = new AlertDialog.Builder(
Activity.this);
alertdialog.setTitle("Title ");
alertdialog.setMessage("The MEssage ");
LayoutInflater layoutinf= LayoutInflater.from(Activity.this);
final View view = layoutinf.inflate(R.layout.layoutfile, null);
alertdialog.setView(view);
alertdialog.setPositiveButton("Button1",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//do something
}
});
alertdialog.show();
Any pointers will be helpful.
thanks
Upvotes: 0
Views: 439
Reputation: 176
For 2nd question alert dialog should be like this :
AlertDialog.Builder alertdialog= new AlertDialog.Builder(this);
alertdialog.setTitle("Title");
alertdialog.setPositiveButton("OK", okListener);
alertdialog.setNegativeButton("Cancel", cancelListener);
AlertDialog alertdialogDlg = alertdialog.create();
alertdialogDlg.show();
public DialogInterface.OnClickListener okListener = new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//do something
}
};
Upvotes: 1