i m trying to set an id to an item of the actionbarsherlock, but i'm getting this "Cannot invoke setId(int) on the primitive type void"
menu.add("new")
.setIcon(R.drawable.icon_1)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
.setId(R.id.newone);
You have two problems, one setShowAsAction
returns void
, so you cannot chain another call on it.
Second, MenuItem
has no setID
method. You cannot change the id after the item is created. To set an ID, you have to do it in the [add
method] from Menu
2,
menu.add("new", myItemId, myOrder, "TEXT" )
.setIcon(R.drawable.icon_1, )
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With