I have tried that. But its not working in M. I am not able to remove
defalut options of floating text selection toolbar like we used to do for
5.0.1 and below. We could completely overide the options in contextual
actionbar. Is there anyway to get it done in M??
On Monday, February 22, 2016 at 4:48:38 PM UTC+5:30, 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 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/b37456cf-0084-4728-b7fe-f4273bd4e224%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.