Home > Mobile >  Novice to solve, Android studio the webview to browse the web
Novice to solve, Android studio the webview to browse the web

Time:09-17

Paste the code
<? The XML version="1.0" encoding="utf-8"?>
XMLNS: tools="http://schemas.android.com/tools"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: orientation="vertical"
The android: id="@ + id/actiity_main"


Android: layout_width="match_parent"
Android: layout_height="wrap_content"
The android: orientation="horizontal" & gt;
The android: id="@ + id/etURL"
Android: layout_width="0 dp"
Android: layout_weight="1"
Android: layout_height="wrap_content"/& gt;
The android: id="@ + id/btnSend"
Android: layout_width="0 dp"
Android: layout_weight="1"
Android: layout_height="wrap_content"
Android: text="page"/& gt;



The android: id="@ + id/webiew"
Android: layout_width="match_parent"
Android: layout_height="match_parent" & gt;


Java classes

Package com. Example. LJK. Webviewdemo;

The import android.net.Uri;
The import android. Support. V7. App. AppCompatActivity;
The import android. OS. Bundle;
The import android. View. The view;
The import android. Its. ConsoleMessage;
The import android. Its. ValueCallback;
The import android. Its. WebChromeClient;
The import android. Its. WebView;
The import android. Its. WebViewClient;
The import android. Widget. The Button;
The import android. Widget. The EditText;

Public class MainActivity extends AppCompatActivity {
The EditText etURL;
The Button btnSend;
The WebView WebView.
@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
setContentView(R.layout.activity_main);
EtURL=(EditText) the findViewById (R.i d.e tURL);
BtnSend=(Button) the findViewById (R.i db tnSend);
The webView=(webView) the findViewById (R.i d.w ebview);
BtnSend. SetOnClickListener (new View. An OnClickListener () {//click to access button
@ Override
Public void onClick (View View) {
WebView. GetSettings (.) setJavaScriptEnabled (true);//set the WebView supports JavaScript
WebView. LoadUrl (etURL. GetText (). The toString (). The trim ());//load the url corresponding page
WebView. SetWebViewClient (new WebViewClient ()//set the client's behavior in a webView
{
//let the WebView to respond after click the page URL
@ Override
Public Boolean shouldOverrideUrlLoading (WebView view, String url)
{
The loadUrl (url);//according to the incoming parameters to load a new page
Return super. ShouldOverrideUrlLoading (view, url);
}
});
}
});
}
}



No response after click on the interface, not to jump to web interface,

CodePudding user response:

This device can connect to the Internet you?

CodePudding user response:

reference 1st floor ultrapro response:
you this device can connect to the Internet?



Equipment can be normal access to the Internet browser

CodePudding user response:

Url to write full: http://www.baidu.com

CodePudding user response:

Look to network access and to no,

CodePudding user response:

Network access
CodePudding user response:

Add permissions to

CodePudding user response:

GPOGPO

CodePudding user response:

This added permissions cannot run
  • Related