Çok basit, bu kod satırlarını entegre etmeyi deneyin, önce Android Manifest dosyasında izin alın
<uses-permission android:name="android.permission.INTERNET" />
sonra Activity.xml dosyanıza biraz kod yazın
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.MainActivity">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/help_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
Ardından bu kodu MainActivity.java dosyanıza yazın
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class MainActivity extends Activity{
private WebView mWebview ;
String link = "";// global variable
Resources res;// global variable
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_modernherbal_main);
mWebview = (WebView) findViewById(R.id.help_webview);
WebSettings webSettings = mWebview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
final Activity activity = this;
mWebview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
});
mWebview .loadUrl("http://www.example.com");
}
}
Bunu deneyin, sorununuzu çözmenize yardımcı olacak