webview设置可点击的false

时间:2011-08-20 05:19:48

标签: android

对于按钮,有“假点击”的方法。功能是btn.setClickable(false);

webview可以使用同样的东西吗? 我使用webviewClient& setOnTouchListener喜欢这样:

tns_btn_1.setOnTouchListener(this);
                client = new WebViewClient(){ 
                    @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { 
                        handler.sendEmptyMessage(CLICK_ON_URL);
                        return false;
                    } 
                }; 
                tns_btn_1.setWebViewClient(client);
                tns_btn_1.setVerticalScrollBarEnabled(false);
                tns_btn_1.loadUrl(first); 
public boolean onTouch(View v, MotionEvent event) {
    if (v.getId() == R.id.tns_wv_firstnumber && event.getAction() == MotionEvent.ACTION_DOWN){
        //handler.sendEmptyMessageDelayed(CLICK_ON_WEBVIEW, 500);
        Toast.makeText(this, "first clicked", Toast.LENGTH_SHORT).show();
    }
 return false;
}

@Override
public boolean handleMessage(Message msg) {
    if (msg.what == CLICK_ON_URL){
        handler.removeMessages(CLICK_ON_WEBVIEW);
        return true;
    }
    if (msg.what == CLICK_ON_WEBVIEW){

        Toast.makeText(this, "WebView clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
}

0 个答案:

没有答案