/ * I have a problem with wierd, inside OnMenuItemClickListener I call the warning dialog that I did, but it seems that when I call the warning dialog, it does not appear at the right moment, only after onMenuItemClick finishes. what am i doing worng? * /
class MyListMenuListener implements OnMenuItemClickListener
{
private String TAG;
@Override
public boolean onMenuItemClick(MenuItem item)
{
if (item.getItemId() == saveRoute.getItemId())
{
alertDialogSaveFile();
}
// ...
private void alertDialogSaveFile()
{
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Save your current map");
alert.setMessage("Please insert name for this route");
final EditText saveNameInput = new EditText(TwittListActivity.this);
alert.setView(saveNameInput);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
nameInput = saveNameInput.getText().toString();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
}
});
AlertDialog ad = alert.create();
ad.show();
}
source
share