/*I have some wierd problem, inside OnMenuItemClickListener, i am calling an alert dialog which i made, but it seems like, when i call the alert dialog, it doesnt show it on right moment, only after onMenuItemClick finish. what am i doing worng? */
class MyListMenuListener implements OnMenuItemClickListener
{
private String TAG;
@Override
public boolean onMenuItemClick(MenuItem item)
{
if (item.getItemId() == saveRoute.getItemId())
{
alertDialogSaveFile();
//nameInput = "testone.txt";
//some operations
// ...
// return true;
}
// ...
/*the wierd thing is that the alert dialog doesnt show up on the same moment i call it..
only after the onMenuItemClick operation ends (with return)
and this is how my alertdialog looks like:*/
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();
}
//Thanks!
//ray.