Android webview onTouch()don';不正常工作
我的代码:Android webview onTouch()don';不正常工作,android,android-webview,Android,Android Webview,我的代码: final WebView webView1 = (WebView)findViewById(R.id.example); webView1.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Intent intent = new Intent(Ads.this, G
final WebView webView1 = (WebView)findViewById(R.id.example);
webView1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Intent intent = new Intent(Ads.this, General.class);
startActivity(intent);
finish();
return false;
}
});
webView1.getSettings().setJavaScriptEnabled(true);
webView1.setBackgroundColor(Color.TRANSPARENT);
StringBuilder htmlData = new StringBuilder("<html>");
htmlData.append("<head></head>");
htmlData.append("<body style='margin:0;padding:0;'>");
htmlData.append("banner from my websive with link");
htmlData.append("</body>");
htmlData.append("</html>");
webView1.loadData(htmlData.toString(),"text/html", "ISO 8859-1");
final WebView WebView 1=(WebView)findViewById(R.id.example);
webView1.setOnTouchListener(新视图.OnTouchListener(){
公共布尔onTouch(视图v,运动事件){
意图=新意图(Ads.this,General.class);
星触觉(意向);
完成();
返回false;
}
});
webView1.getSettings().setJavaScriptEnabled(true);
webView1.setBackgroundColor(Color.TRANSPARENT);
StringBuilder htmlData=新的StringBuilder(“”);
htmlData.append(“”);
htmlData.append(“”);
附加(“带链接的我的网站的横幅”);
htmlData.append(“”);
htmlData.append(“”);
加载数据(htmlData.toString(),“text/html”,“ISO 8859-1”);
请问,我哪里有问题
如何启动first Intent和browserver窗口之后
PS:我不知道为什么,但如果我单击webview,意图将在同一时间启动5次。尝试使用此代码
webView1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
Intent intent = new Intent(Ads.this, General.class);
startActivity(intent);
finish();
}
return true;
}
});
错误:操作数类型MotionEvent和inthuh不兼容,解决了一个问题,意图启动1次。但现在,浏览器服务器窗口永远不会打开。