好日子所有,如何獲得在Android Studio中使用的WebView
我做一個簡單的應用程序(實踐的目的)使用在Android Studio中一的WebView所有URL。我希望我的應用能夠烘烤我輸入/瀏覽的所有網址。例如,當我打開Facebook時,它會將其網址烘烤,當我登錄到我的帳戶時,它會再次爲我的Facebook帳戶敬酒,聽起來就像那樣。這是我的代碼。我是新東西的東西,任何建議或幫助將不勝感激。非常感謝。
XML佈局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.nevigrof.ymuc.Back_order">
<WebView
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:id="@+id/webview1"/>
</RelativeLayout>
的Java代碼
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_survey_form);
webview = (WebView) findViewById(R.id.webview1);
webview.setWebViewClient(new MyWebViewClient());
openURL();
}
private void openURL() {
webview.requestFocus(View.FOCUS_DOWN | View.FOCUS_UP);
webview.loadUrl("http:/https://www.facebook.com/");
webview.getSettings().setJavaScriptEnabled(true);
String webUrl = webview.getUrl();
Toast.makeText(Back_order.this, webUrl, Toast.LENGTH_LONG).show();
}
}
有一個在webview.loadUrl() – jomartigcal