Adding to favorites

Discussion in 'Application Development' started by bscarl88, Aug 11, 2010.

  1. bscarl88

    bscarl88 Member

    Jul 2, 2010
    I have a tab widget with 3 tabs, each with a listview inside. I setup a context menu so that when I click and hold on one of the list items it brings up a box saying add to favorites. The problem is, I don't know how to pass the selected listview item to the ArrayList in Favorites, or receive it in Favorites class. I have tried bundling and putExtra but I can't get them to work, I am pretty new to all this and even after reading many guides, I am not very good but here is the code for my context menu so far (after I deleted the messy code I tried before).

    Code (Text):
    2. public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
    3.     {
    4.         super.onCreateContextMenu(menu, v, menuInfo);
    5.         menu.add(0, FAV_ID, 0, R.string.fav_insert);
    6.     }
    7.     public boolean onContextItemSelected(MenuItem item, View v)
    8.     {
    9.         int position = 0;
    10.         switch(item.getItemId())
    11.         {
    12.         case FAV_ID:
    14.             AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    15.             //TODO add the code that adds the selected list item to the favorites class.
    16.             return true;
    17.         }
    18.         return super.onContextItemSelected(item);
    19.     }
    I have the ArrayList publicly declared in my Favorites class

    any help would be appreciated


Share This Page