Ich bin zuerst Android Test App erstellen.Android WebView (Link offen)
Ich benutze Webview-Formular, und ich füge eine URL ein, und wenn ich app laufe, funktioniert es gut.
Aber wenn ich App öffnen, und klicken Sie auf einen anderen Seitenlink, als ich ausgewählte Liste, Beispiel, öffnen Sie es auf "Google Chrome". Aber ich möchte es im Webview öffnen.
Ich denke das klar erklärt.
activity_mail.xml
<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" android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" tools:context=".MainActivity">
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/webView"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
</RelativeLayout>
MainActivity.java
package com.example.webviewapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "http://example.com";
WebView view=(WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
}
}
Vielen Dank!
Es ist Arbeit, es ist so einfach. Vielen Dank! –