GGCO
GGCO

Reputation: 183

Android ContextMenu to change button text

Here's my problem:

I have a button in my android application that when I longClick it a context menu appears with a list of values that a user can choose from.

What I need to do is when the user chooses a value, I need the button's text to be that value. I can't figure out how to get the onContextItemSelected listener to remember which button triggered the context menu and then set it's text to the selected item.

Thanks for any help/tips you can give me.

Upvotes: 0

Views: 475

Answers (2)

dmon
dmon

Reputation: 30168

Hmmmm, I believe you can do the following:

@Override
public boolean onContextItemSelected(MenuItem item) {
  AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  View longClickedView = info.targetView;
  ...
}

Upvotes: 0

user468311
user468311

Reputation:

Have you tried this?

Upvotes: 1

Related Questions