Android:+WebView+demo
来源:互联网 发布:java json数组遍历 编辑:程序博客网 时间:2024/05/17 23:34
项目地址: http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/Samples/WebViewDemo
Using WebViews
WebViews allow an application to dynamically display HTML and execute JavaScript, without relinquishing control to a separate browser application. This article introduces the WebView classes and provides a sample application that demonstrates its use.
package com.google.android.webviewdemo;import android.app.Activity;import android.os.Bundle;import android.os.Handler;import android.util.Log;import android.webkit.JsResult;import android.webkit.WebChromeClient;import android.webkit.WebSettings;import android.webkit.WebView;/** * Demonstrates how to embed a WebView in your activity. Also demonstrates how * to have javascript in the WebView call into the activity, and how the activity * can invoke javascript. * <p> * In this example, clicking on the android in the WebView will result in a call into * the activities code in {@link DemoJavaScriptInterface#clickOnAndroid()}. This code * will turn around and invoke javascript using the {@link WebView#loadUrl(String)} * method. * <p> * Obviously all of this could have been accomplished without calling into the activity * and then back into javascript, but this code is intended to show how to set up the * code paths for this sort of communication. * */public class WebViewDemo extends Activity { private static final String LOG_TAG = "WebViewDemo"; private WebView mWebView; private Handler mHandler = new Handler(); @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); WebSettings webSettings = mWebView.getSettings(); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(false); mWebView.setWebChromeClient(new MyWebChromeClient()); mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo"); //mWebView.loadUrl("file:///android_asset/demo.html"); mWebView.loadUrl("http://www.baidu.com"); } final class DemoJavaScriptInterface { DemoJavaScriptInterface() { } /** * This is not called on the UI thread. Post a runnable to invoke * loadUrl on the UI thread. */ public void clickOnAndroid() { mHandler.post(new Runnable() { public void run() { mWebView.loadUrl("javascript:wave()"); } }); } } /** * Provides a hook for calling "alert" from javascript. Useful for * debugging your javascript. */ final class MyWebChromeClient extends WebChromeClient { @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { Log.d(LOG_TAG, message); result.confirm(); return true; } }}
http://code.google.com/p/apps-for-android/
A collection of useful, open source applications that demonstrate features of the Android platform:
- Amazed: A simple but addictive accelerometer-based marble-guidance game.
- AndroidGlobalTime: a full representation of the Earth that you can spin around.
- AnyCut: A utility that lets users create Home screen shortcuts to nearly anything in the system.
- Clickin2DaBeat: A game that mashes up YouTube with custom rhythm-game logic.
- DivideAndConquer: a game in which you must isolate bouncing balls by creating walls around them.
- HeightMapProfiler: A simple 3D performance testing tool that renders a 3D height map.
- LOLcat Builder: O HAI. I CN HAS CHEEZBURGER?! IM N UR PHONE, CAPTIONIN UR PHOTOS.
- Panoramio: An app that shows you nearby photos and points of interest.
- Photostream: An app that lets you view photostreams from online photo-hosting services.
- Radar: A radar-style relative location display view, used by Panoramio and others.
- RingsExtended: A utility that provides enhanced control over ringtones.
- Samples: Miscellaneous examples showing features of the Android platform (among which OpenGL ES).
- SpriteMethodTest: An application that compares the speed of various 2D sprite drawing methods.
- Translate: Translates more than 150 language pairs with Google's translation service.
- WebViewDemo: How Java and JavaScript can call each other inside a WebView.
- WikiNotes: A wiki note pad that uses intents to navigate to wiki words and other rich content stored in the notes.
- Android:+WebView+demo
- Android WebView Demo
- Android WebView demo
- Android WebView与服务端交互Demo
- Android demo-->webview实现js交互
- WebView Demo
- Android WebView与JavaScript交互操作(Demo)
- 【android】带加载进度条的WebView (附demo下载)
- WebView的Demo
- WebView小Demo
- webview demo apk 下载
- WebView 控件使用Demo
- WebView.loadData()Demo
- 有道词典Demo(WebView)
- 有道词典Demo(WebView)
- 有道词典Demo(WebView)
- 有道词典Demo(WebView)
- 有道词典Demo(WebView)
- [转]plsql 远程连接,不用安装Oracle客户端,使用pl/sql配置远程登陆
- 计算机中的“句柄”是什么意思?
- 加班调休报表
- EF 4.1 Code First Walkthrough
- 教你如何提升网站打开速度
- Android:+WebView+demo
- RMAN备份与恢复(2)——恢复有备份的表空间和数据文件!
- Linux搭建apache简易媒体服务器
- cadence的3个中文教材
- 世界上有两件事最难:
- 如何查看ORACLE中正在运行的存储过程
- Android---tableLayout(表单布局)
- 《Effective+C#》Item+9:区别和认识四个判等函数(转载)
- js中基本上8中情况的逻辑false情况