In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to use WebView components, the content is very detailed, interested friends can refer to, hope to be helpful to you.
A high-performance webkit kernel browser is built into the Android phone, which is encapsulated into a WebView component in SDK, which can be used to browse web content. So, how do you use it?
Load a component using the WebView control for the first time
1) mainfest.xml adds internet permission
Manifest >
2) add webView components to layout
LinearLayout >
3) add activity
Package com.example.webview1; import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.Menu; import android.webkit.WebView; import android.webkit.WebViewClient; public class WebViewActivity extends Activity {private WebView webView; @ Override public void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_web_view); webView = (WebView) findViewById (R.id.webview) / / set javasctipt available webView.getSettings () .setJavaScriptEnabled (true); / / load url, but it will not be displayed, pay attention! WebView.loadUrl ("http://www.baidu.com"); / / specify display control (class) webView.setWebViewClient (new myWebViewClient ());} @ Override public boolean onCreateOptionsMenu (Menu menu) {getMenuInflater () .inflate (R.menu.activity_web_view, menu); return true } / / to make the fallback key work @ Override public boolean onKeyDown (int keyCode, KeyEvent event) {/ / TODO Auto-generated method stub if (keyCode==event.KEYCODE_BACK&&webView.canGoBack ()) {webView.goBack (); return true;} return super.onKeyDown (keyCode, event) } / * * webView View client * @ author Administrator * * / class myWebViewClient extends WebViewClient {@ Override public boolean shouldOverrideUrlLoading (WebView view, String url) {/ / TODO Auto-generated method stub / / return super.shouldOverrideUrlLoading (view, url); webView.loadUrl (url); return true }
4) ok! It's done, run it!
5) bluestacks for simulator
About how the use of WebView components is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.