在android中使用webview [英] using of webview in android
本文介绍了在android中使用webview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此网站有一个重要的部分是上传部分,现在当应用程序加载此网站时,当我触摸选择文件按钮时,没有任何事情发生。
有没有代码可以解决这个问题?
this site has a important part that is uploading part and now when the application load this site and when I touch choose file button nothing happen.
is there any code can solve this problem?
推荐答案
为了将WebView添加到您的应用程序,您必须添加< webview>元素到你的xml布局文件。它的语法如下 -
< webview xmlns:android =http://schemas.android.com/apk/res/android>
android:id =@ + id / webview
android:layout_width =fill_parent
android:layout_height =fill_parent
/>
为了使用它,你必须在Java文件中获得这个视图的引用。要获取引用,请创建WebView类的对象。它的语法是 -
WebView browser =(WebView)findViewById(R.id.webview);
为了将Web URL加载到WebView中,您需要调用WebView类的方法loadUrl(String url),指定所需的URL。它的语法是:
browser.loadUrl(http://www.tutorialspoint.com);
In order to add WebView to your application, you have to add <webview> element to your xml layout file. Its syntax is as follows −
<webview xmlns:android="http://schemas.android.com/apk/res/android">
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
In order to use it, you have to get a reference of this view in Java file. To get a reference, create an object of the class WebView. Its syntax is −
WebView browser = (WebView) findViewById(R.id.webview);
In order to load a web url into the WebView, you need to call a method loadUrl(String url) of the WebView class, specifying the required url. Its syntax is:
browser.loadUrl("http://www.tutorialspoint.com");
这篇关于在android中使用webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文