Android WebView的使用
2010-07-19 23:13:00 来源:WEB开发网//判断输入的内容是不是网址
if(URLUtil.isNetworkUrl(url)){
wv.loadUrl(url);
}else{
et.setHint("输入的网址不合法,请重新输入");
// et.setText("输入的网址不合法,请重新输入");
}
}
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK && wv.canGoBack()){
wv.goBack();//返回前一个页面
return true;
}
return super.onKeyDown(keyCode, event);
}
}
package com.Aina.Android;
import android.app.Activity;
import android.app.AlertDialog;
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);
更多精彩
赞助商链接