u can have listeners in menu.xml. Set the onClick property it will work
On Wed, Jul 27, 2016 at 11:19 PM, Paul Klauser <[email protected]> wrote: > Haha I actually found that solution earlier today, thanks for sharing! > Only problem now is that I can't actually detect if the user selected any > of the options in the action mode. > > On Wednesday, July 27, 2016 at 12:37:30 PM UTC-4, Vishal Kumar Singh wrote: >> >> Hi Paul, >> >> Actually yes >> >> I just used onActionmodeStarted callback in activity to override the >> options and it worked. >> >> So basically rather doing this in the view i did in activity. >> >> On Wed, Jul 27, 2016 at 4:01 AM, Paul Klauser <[email protected]> wrote: >> >>> Hey I'm having the same issue, did you ever find a solution? >>> >>> On Monday, February 22, 2016 at 6:18:38 AM UTC-5, Vishal Kumar Singh >>> wrote: >>>> >>>> Hi, >>>> >>>> I had customized the Contextual Action mode appearing on text selection >>>> in webview. In android M its not working, how to get top toolbar behaviour >>>> in Android M or customize the new contextual menu appearing in Android M.?? >>>> >>>> public class CustomWebView extends WebView { >>>> >>>> private ActionMode.Callback mActionModeCallback; >>>> >>>> public CustomWebView(Context context) { >>>> super(context); >>>> } >>>> >>>> public CustomWebView(Context context, AttributeSet attrs) { >>>> super(context, attrs); >>>> } >>>> >>>> @Override >>>> public ActionMode startActionMode(ActionMode.Callback callback) { >>>> mActionModeCallback = new CustomActionModeCallback(); >>>> return startActionMode(mActionModeCallback); >>>> } >>>> >>>> private class CustomActionModeCallback implements >>>> ActionMode.Callback { >>>> >>>> @Override >>>> public boolean onCreateActionMode(ActionMode mode, Menu menu) { >>>> MenuInflater inflater = mode.getMenuInflater(); >>>> inflater.inflate(R.menu.context_menu, menu); >>>> return true; >>>> } >>>> >>>> @Override >>>> public boolean onPrepareActionMode(ActionMode mode, Menu menu) { >>>> return false; >>>> } >>>> >>>> @Override >>>> public boolean onActionItemClicked(ActionMode mode, MenuItem >>>> item) { >>>> switch (item.getItemId()) { >>>> case R.id.copy: >>>> Toast.makeText(getContext(), "Copy", >>>> Toast.LENGTH_SHORT).show(); >>>> mode.finish(); // Action picked, so close the CAB >>>> return true; >>>> case R.id.paste: >>>> Toast.makeText(getContext(), "Paste", >>>> Toast.LENGTH_SHORT).show(); >>>> mode.finish(); >>>> return true; >>>> // Create a case for every item >>>> default: >>>> mode.finish(); >>>> return false; >>>> } >>>> } >>>> >>>> @Override >>>> public void onDestroyActionMode(ActionMode mode) { >>>> clearFocus(); >>>> } >>>> } >>>> } >>>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Android Developers" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/android-developers/-KMOEsGdPcY/unsubscribe >>> . >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/android-developers. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/android-developers/8aae65d2-00d8-41aa-b5d6-7101503ebdb1%40googlegroups.com >>> <https://groups.google.com/d/msgid/android-developers/8aae65d2-00d8-41aa-b5d6-7101503ebdb1%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to a topic in the > Google Groups "Android Developers" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/android-developers/-KMOEsGdPcY/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/android-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/android-developers/21350354-7b83-4ca8-a5a8-8560a9c593e8%40googlegroups.com > <https://groups.google.com/d/msgid/android-developers/21350354-7b83-4ca8-a5a8-8560a9c593e8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/CADt3-o9%3DAPRm0e0xaU7kH%3DfR0xULUUsVBnunHR2wweRo6TEVLQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

