Your View isn't a TextView. It is a RelativeLayout. Call
findViewById() on the RelativeLayout to find the TextView you are
interested in. Or, if you are using the holder pattern, get the holder
via getTag() and use the holder to get to the TextView.

On Thu, Sep 16, 2010 at 6:24 PM, Liorry <[email protected]> wrote:
> Hello, Trying to set ContextMenu title according to the ListView
> clicked item. The ListView contains Bookmarks list -> FAVICON +
> BOOKMARK TITLE
>
> @Override
>    public void onCreateContextMenu(ContextMenu menu, View v,
> ContextMenuInfo menuInfo) {
>      super.onCreateContextMenu(menu, v, menuInfo);
>      menu.add(0, EDIT_ID, 0, R.string.menu_edit);
>      menu.add(0, DELETE_ID, 0, R.string.menu_delete);
>      menu.add(0, SHARE_ID, 0, R.string.menu_share);
>
>      AdapterView.AdapterContextMenuInfo info =
> (AdapterView.AdapterContextMenuInfo)menuInfo;
>      View itemID = (info.targetView);
>      menu.setHeaderTitle("bla" + itemID);
>    }
> When I run this code it shows the
> android.widget.relativelay...@423d2389 or whatever and if I change the
> itemID to String itemID = ((TextView)
> info.targetView).getText().toString(); I get force close on long click
> even though no errors are shown in Eclipse or when I run the app.
>
> I also want to get the favicon in the same way...
>
> Appreciate the help!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to