Android - fail to call default paste method

这一生的挚爱 提交于 2019-12-14 02:40:03

问题


I made custom contextual action bar in Webview.

And there are copy and paste buttons.

Copy action is working with ClipboardManager.

But pasting method doesn't work.

I referenced this link and problem with setting enabled.

MenuItem mPasteItem = menu.findItem(R.id.menu_paste);
if (!(clipboard.hasPrimaryClip())) {
  mPasteItem.setEnabled(false);
} else if (!(clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN))) {        
    mPasteItem.setEnabled(false);
} else {        
    mPasteItem.setEnabled(true);
}

If I pass setEnabled method, there is no response even "if (pasteData != null) { return;}" called.

Any idea to work this?


EDIT I checked with debug mode, my menu item of pasting operation is setenabled default.

So I think this process(setting enabled) is not necessary.

But Still, paste operation after return; called like below.

pasteData = item.getText();

if (pasteData != null) {
   return;

What is the problem?

来源:https://stackoverflow.com/questions/36130354/android-fail-to-call-default-paste-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!