我使用WebView做了一个示例应用程序,在该Web视图中,URL来自Web服务。它工作正常,但如果我点击该WebView内的任何链接,它将自动转到默认的Web浏览器。但我只想在我的应用程序Web视图中打开。在这里我的代码:Android WebView在WebView中单击打开并非默认浏览器?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url ="http://www.cementegypt.com/m/";
WebView view =(WebView) this.findViewById(R.id.webView1);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
非常感谢所有回复 –
我可以为webchrome客户端做同样的工作吗 – devutkarsh
@DevUtkarsh对不起,我没有使用过'WebChromeClient',尝试没有什么坏处我猜。 –