本文介绍了跟踪机器人的WebView的选择文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在机器人的WebView我们可以能够选择在网页中的文本。选择完以后,面包会出现像文字复制到剪贴板。是否其能够避免吐司?我也想选择文本后调用函数。我怎样才能做到这一点?

帮我...

解决方案

 公共布尔onTouch(视图V,MotionEvent事件){
    如果(event.getAction()== android.view.MotionEvent.ACTION_UP){
        //当用户选择完成这个循环将执行获得
        // web视图中选中的文本。
        如果(mark_text ==真)
        {
             mark_text = FALSE;
             clipboardManager.setText(XXXXXX);
             webView.postDelayed(onClipBoard,1000);
        }
    }
 }


私人可运行onClipBoard =新的Runnable(){
   公共无效的run(){
            //如果选定的文本复制到剪贴板吐司将显示
            //正确的文本,否则其他部分将执行
      如果(!clipboardManager.getText()。的toString()。equalsIgnoreCase(XXXXXX)){
            Toast.makeText(getApplicationContext(),
                    选择的文本=+ clipboardManager.getText()。的toString()
                    Toast.LENGTH_LONG).show();
            clipboardManager.setText(XXXXXX);

      } 其他 {
           webView.postDelayed(onClipBoard,1000);
      }
   }
};
 

In android webview we can able to select the text in web pages. After selection finished , the toast will appear like "text copied to clipboard". Whether its possible to avoid that toast? Also i want to call a function after selecting text. how can i do this?

help me...

解决方案
public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
        // when user finished selection this loop will execute to get
        // selected text in webview.
        if(mark_text == true)
        {
             mark_text = false;
             clipboardManager.setText("XXXXXX");
             webView.postDelayed(onClipBoard, 1000);
        }
    }
 }


private Runnable onClipBoard=new Runnable() {
   public void run() {
            // if selected text is copied in clipboard toast will show the
            // correct text otherwise else part will execute
      if (!clipboardManager.getText().toString().equalsIgnoreCase("XXXXXX")) {
            Toast.makeText(getApplicationContext(),
                    "selected Text = " + clipboardManager.getText().toString(),
                    Toast.LENGTH_LONG).show();
            clipboardManager.setText("XXXXXX");

      } else {
           webView.postDelayed(onClipBoard, 1000);
      }
   }
};

这篇关于跟踪机器人的WebView的选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:14
查看更多