布局文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/editText1"> <requestFocus></requestFocus> </EditText> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:text="确定" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <Button android:text="取消" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> </LinearLayout> <WebView android:id="@+id/webView1" android:layout_width="match_parent" android:layout_height="match_parent"></WebView> </LinearLayout>
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class Mp3infoActivity extends Activity { /** Called when the activity is first created. */ private Button button_Ok,button_Reset; private WebView webView; private EditText editText; private WebSettings webSettings; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button_Ok=(Button)findViewById(R.id.button1); button_Reset=(Button)findViewById(R.id.button2); webView=(WebView)findViewById(R.id.webView1); webSettings=webView.getSettings(); webSettings.setJavaScriptEnabled(true);//支持JS webSettings.setUseWideViewPort(true);////让浏览器支持用户自定义view webSettings.setBuiltInZoomControls(true);//支持缩放 webSettings.setAllowFileAccess(true);// 允许访问android系统数据文件 editText=(EditText)findViewById(R.id.editText1); button_Ok.setOnClickListener(new ButtonListenr()); button_Reset.setOnClickListener(new ButtonListenr()); } private class ButtonListenr implements OnClickListener{ @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.button1: String stringUrl=editText.getText().toString(); stringUrl=stringUrl.trim();//去掉空格 if (stringUrl.length()==0) { Toast.makeText(getApplicationContext(), "网址为空", Toast.LENGTH_LONG).show(); }else { stringUrl="http://ting.baidu.com/search?key="+stringUrl; webView.loadUrl(stringUrl); } break; case R.id.button2: editText.setText(null); break; default: break; } } } }上图
您还没有登录,请您登录后再发表评论
Android webview 内存泄露的解决方法 最近在activity嵌套webview显示大量图文发现APP内存一直在涨,没法释放内存,查了很多资料,大概是webview的一个BUG,引用了activity导致内存泄漏,所以就尝试传递...
Android Webview虽然提供了页面加载及资源请求的钩子,但是对于h5的ajax请求并没有提供干涉的接口,这意味着我们不能在webview中干涉javascript发起的http请求,而有时候我们确实需要能够截获ajax请求并实现一些功能...
Android WebView 去除标题 利用javacript交互
Android Webview 滑动监听 放大缩小查看网页图片
Android WebView实现自由复制文字
Android webview 加载网页以及本地资源以及SD资源demo,以及加载缓存资源
android webview input=file 失效解决方案
Android WebView播放视频开发中总结的一些经验,希望同大家分享,这个是相应的Demo,一些经验和注释都在代码中写到。
android webview模拟网页post操作
android webview拨打电话 关注博客http://himici.com
Android webview 播放视频、文字复制
android webview加载网页获取对应url 参数值的方法(csdn)————程序
Android webview加载网页
Android webview打开相册选择图片并上传到服务器,(亲测可用)
Android webView拍照与展示相册图片,具体可以查看:https://blog.csdn.net/a748448660/article/details/82389904
android webview 因iframe+target=“_blank “ 导致的页面无法正常打开或获取不到调整url
android webView加载html 并引用本地资源(图片、字体库)
Android下使用Webview实现的HTML5视频播放器,播放本地视频时请加载video目录下的1.html
android WebView上传文件
相关推荐
Android webview 内存泄露的解决方法 最近在activity嵌套webview显示大量图文发现APP内存一直在涨,没法释放内存,查了很多资料,大概是webview的一个BUG,引用了activity导致内存泄漏,所以就尝试传递...
Android Webview虽然提供了页面加载及资源请求的钩子,但是对于h5的ajax请求并没有提供干涉的接口,这意味着我们不能在webview中干涉javascript发起的http请求,而有时候我们确实需要能够截获ajax请求并实现一些功能...
Android WebView 去除标题 利用javacript交互
Android Webview 滑动监听 放大缩小查看网页图片
Android WebView实现自由复制文字
Android webview 加载网页以及本地资源以及SD资源demo,以及加载缓存资源
android webview input=file 失效解决方案
Android WebView播放视频开发中总结的一些经验,希望同大家分享,这个是相应的Demo,一些经验和注释都在代码中写到。
android webview模拟网页post操作
android webview拨打电话 关注博客http://himici.com
Android webview 播放视频、文字复制
android webview加载网页获取对应url 参数值的方法(csdn)————程序
Android webview加载网页
Android webview打开相册选择图片并上传到服务器,(亲测可用)
Android webView拍照与展示相册图片,具体可以查看:https://blog.csdn.net/a748448660/article/details/82389904
android webview 因iframe+target=“_blank “ 导致的页面无法正常打开或获取不到调整url
android webView加载html 并引用本地资源(图片、字体库)
Android下使用Webview实现的HTML5视频播放器,播放本地视频时请加载video目录下的1.html
android WebView上传文件