要使用webView下面的代碼,是否有任何方式進入該網站,而無需輸入整個網址(www.google.com)?目前需要完整輸入網址(http://www.google.com.br)。webView Android應用程序
代碼:
public class MainActivity extends ActionBarActivity {
private EditText editText;
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.url);
webView = (WebView) findViewById(R.id.webViewlayout);
webView.setWebViewClient(new MyBrowser());
}
public void abrirPagina (View v){
String url = editText.getText().toString();
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.loadUrl(url);
}
private class MyBrowser extends WebViewClient{
public boolean overrideUrlLoading (WebView view, String url){
view.loadUrl(url);
return true;
}
}
}
webView.loadUrl(「https://www.google.com.br/?gws_rd=ssl」);是嗎? – IceJOKER