android中的webview的使用,在线等 现需:一android中的webview的使用的demo,最好是提供完整的,可运行的例子,哪位帮帮忙,thanks 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有哪位可分享些资料吗 thanks webview就是把一个网页内容直接显示在你的Activity里呀 多谢楼上的现需:一android中的webview的使用的demo,最好是提供完整的,可运行的例子,哪位帮帮忙,thanks <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_x="0.1dip" android:layout_y="0.1dip" android:layout_weight="1.0" />package com.android.webview;import android.app.Activity;import android.app.ProgressDialog;import android.os.Bundle;import android.os.Handler;import android.webkit.WebChromeClient;import android.webkit.WebView;import android.webkit.WebViewClient;public class WebViewTestActivity extends Activity { /** Called when the activity is first created. */ WebView wv; ProgressDialog pd; Handler handler; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); init(); loadUrl(wv, "http://www.baidu.com/"); handler=new Handler(){ public void handleMessage(android.os.Message msg) { if(Thread.currentThread().isInterrupted()){ switch(msg.what){ case 0: pd.show(); break; case 1: pd.hide(); break; } } }; }; } public void init(){ wv=(WebView) findViewById(R.id.webview); //可用js wv.getSettings().setJavaScriptEnabled(true); //滚动条风格,为0就是不给滚动条留空间,滚动条覆盖在网页上 wv.setScrollBarStyle(0); wv.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { loadUrl(view, url); return super.shouldOverrideUrlLoading(view, url); } }); wv.setWebChromeClient(new WebChromeClient(){ @Override public void onProgressChanged(WebView view, int newProgress) { if(newProgress==100){ handler.sendEmptyMessage(1); } super.onProgressChanged(view, newProgress); } }); pd=new ProgressDialog(WebViewTestActivity.this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setMessage("数据加载中,请稍候..."); } public void loadUrl(final WebView webView,final String url){ new Thread(){ @Override public void run() { handler.sendEmptyMessage(0); webView.loadUrl(url); } }.start(); }} 多谢五楼,程序可运行,可baidu的页面没出来,屏上提示 '找不到网页'什么原因,怎么处理? 可以加我好友,一起探讨Android问题。 你说的网络是什么网络?(这程序我是在手机上运行的,现手机上用手机卡上网的,并在手机浏览器中可进入baidu的。) 有没有报什么异常或者warning、什么的 你加那个网络permission了 加了呀AndroidManifest.xml 如下<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.apis" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".WebViewTestActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET"/></manifest>main.xml 文件如下<?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" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /><WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_x="0.1dip" android:layout_y="0.1dip" android:layout_weight="1.0" /></LinearLayout>你加我q : 350038760 你的项目文件,在我这边运行出来了,可baidu的页面还是没出来,还是提示“找不到网页” 哦,可以运行了,baidu页面也出来了,是手机需设置wan,我把手机卡网络关了,再连办公室的无线wan就好了。 ubuntu编译源码问题 android 关于考勤的问题。。求高人解决方案。。 videoview用代码怎么控制全屏播放? 物理键盘无法使用 android图片高效解码方法 关于sdcard存储问题~~请高手们帮助啊~万谢! Android下如何使用Oprofile,Opcontrol --dump没有任何输出,怎么办? Android程序启动后,如何结束的? 关于GridView的一个问题 在Android Studio中,怎么把按钮放在底部位置,且不随上面的文本移动 Service 多次启动对系统有没有影响? android如何得到服务端的返回值 集合类型
现需:一android中的webview的使用的demo,
最好是提供完整的,可运行的例子,哪位帮帮忙,thanks
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0.1dip"
android:layout_y="0.1dip"
android:layout_weight="1.0" />package com.android.webview;import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;public class WebViewTestActivity extends Activity {
/** Called when the activity is first created. */
WebView wv;
ProgressDialog pd;
Handler handler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
loadUrl(wv, "http://www.baidu.com/");
handler=new Handler(){
public void handleMessage(android.os.Message msg) {
if(Thread.currentThread().isInterrupted()){
switch(msg.what){
case 0:
pd.show();
break;
case 1:
pd.hide();
break;
}
}
};
};
}
public void init(){
wv=(WebView) findViewById(R.id.webview);
//可用js
wv.getSettings().setJavaScriptEnabled(true);
//滚动条风格,为0就是不给滚动条留空间,滚动条覆盖在网页上
wv.setScrollBarStyle(0);
wv.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
loadUrl(view, url);
return super.shouldOverrideUrlLoading(view, url);
}
});
wv.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) {
if(newProgress==100){
handler.sendEmptyMessage(1);
}
super.onProgressChanged(view, newProgress);
}
});
pd=new ProgressDialog(WebViewTestActivity.this);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setMessage("数据加载中,请稍候...");
}
public void loadUrl(final WebView webView,final String url){
new Thread(){
@Override
public void run() {
handler.sendEmptyMessage(0);
webView.loadUrl(url);
}
}.start();
}
}
可baidu的页面没出来,屏上提示 '找不到网页'
什么原因,怎么处理?
(这程序我是在手机上运行的,现手机上用手机卡上网的,并在手机浏览器中可进入baidu的。)
AndroidManifest.xml 如下
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.apis"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".WebViewTestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>main.xml 文件如下
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0.1dip"
android:layout_y="0.1dip"
android:layout_weight="1.0" /></LinearLayout>你加我q : 350038760