When you long press开发者_JAVA技巧 on an email in Gmail application the dialog box is shown. I'm wondering is it just a dialog or an activity represented as dialog? Thank you.
Probably it should be a Dialog
and when you select/click the item it may be open an Activity
based on the type of commands. However an Activty
can be displayed as a Dialog
but here as the items in the dialog are related to the context of the same activty therfore it can't be a new activty here.
Your screen shot code should look like this. Here there is no need to dismiss your dialog, when selected option it automatically dismissed.
AlertDialog dialog ;
Charsequence str[]={"Test1","Test2"};
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("Your Title Here");
builder.setItems(str, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
//here you can use like this... str[position]
}
});
dialog = builder.create();
dialog.show();
精彩评论