Android WebView的使用
2010-07-19 23:13:00 来源:WEB开发网import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.URLUtil;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Test extends Activity {
/** Called when the activity is first created. */
private EditText et = null;
private Button btn = null;
private WebView wv = null;
private WebSettings ws = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et = (EditText) this.findViewById(R.id.EditText01);
btn = (Button) this.findViewById(R.id.Button01);
wv = (WebView) this.findViewById(R.id.WebView);
ws = wv.getSettings();
ws.setAllowFileAccess(true);//设置允许访问文件数据
ws.setJavaScriptEnabled(true);//设置支持javascript脚本
ws.setBuiltInZoomControls(true);//设置支持缩放
wv.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view,String url){
//当有新连接时,使用当前的 WebView
view.loadUrl(url);
return true;
}
});
wv.setWebChromeClient(new WebChromeClient(){
public boolean onJsAlert(WebView view,String url,String message,final
更多精彩
赞助商链接