0

I have a listView and want on long press show my custom dialog. How I cat to do this? All my attempts brought nothing to me. Dialog never shows, ANR is occurs.

 @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);

}

Rating dialog never shows, toast works perfectly. It is necessary to show context menu befor dialog or I can launch my dialog from onCreateContextMenu()?

Thanks!

Georgy Gobozov
  • 13,633
  • 8
  • 72
  • 78
  • My activity runs inside activity group. Answer found http://stackoverflow.com/questions/4396221/how-to-show-alert-inside-an-activity-group – Georgy Gobozov Sep 27 '11 at 06:48

1 Answers1

0

You may need to show the context menu before the dialog. You could then have an option to rate.

coder_For_Life22
  • 26,645
  • 20
  • 86
  • 118