跟踪android webview中的选择文本

Pra*_*nth 6 android

在android webview中,我们可以选择网页中的文本.选择完成后,吐司将显示为"文本复制到剪贴板".是否可以避免吐司?我也想在选择文本后调用一个函数.我怎样才能做到这一点?

帮我...

Pra*_*nth 5

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);
      }     
   }
};
Run Code Online (Sandbox Code Playgroud)