[英]Android webview onTouch() don't working right
我的代码:
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");
拜托,我哪里有问题?
如何先启动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;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.