0
我有一个listView,并希望在长按显示我的自定义对话框。我如何做到这一点?我所有的尝试都没有给我带来什么。对话框从不显示,ANR发生。Android。从上下文菜单启动对话框
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
if (type == 1) {
menu.add("rating");
}
}
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
int rating = msg.arg1;
System.out.println("Rating = " + rating);
}
};
System.out.println("Create rating dialog");
Toast.makeText(MyListActivity.this, "Ass", Toast.LENGTH_SHORT).show();
// new RatingDialog(MyListActivity.this, handler).show();
return super.onContextItemSelected(menuItem);
}
评级对话从不显示,敬酒完美的作品。有必要显示上下文菜单对话框,或者我可以从onCreateContextMenu()启动我的对话框?
谢谢!
我的活动在活动组内运行。答案发现http://stackoverflow.com/questions/4396221/how-to-show-alert-inside-an-activity-group –