现在,当我按下特定按钮时,它会启动将网页打开到 webView 中的意图,但它会打开浏览器应用程序,显示不是我想要的地址栏。
在做了一些研究之后,我发现我可以使用 shouldOverrideUrlLoading() 方法来阻止这种情况的发生,只需在 webView 中打开页面,但我不知道如何在我的代码中实现这个方法,非常感谢帮助!
这是我在课堂上打开网页的内容:
public class Codes extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.codes);
View titleView = getWindow().findViewById(android.R.id.title);
if (titleView != null) {
ViewParent parent = titleView.getParent();
if (parent != null && (parent instanceof View)) {
View parentView = (View)parent;
parentView.setBackgroundColor(Color.rgb(228, 108, 10));
}
}
WebView codes = (WebView)findViewById(R.id.codesWebView);
codes.getSettings().setJavaScriptEnabled(true);
codes.loadUrl("http://dev10.affirmaconsulting.com:24009/keyentry");
shouldOverrideUrlLoading(codes, "http://dev10.affirmaconsulting.com:24009/keyentry");
}
}