Android WebView的使用
2010-07-19 23:13:00 来源:WEB开发网return true;
}
//设置网页加载的进度条
public void onProgressChanged(WebView view,int newProgress){
Test.this.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, newProgress*100);
super.onProgressChanged(view, newProgress);
}
//设置应用程序的标题
public void onReceivedTitle(WebView view,String title){
Test.this.setTitle(title);
super.onReceivedTitle(view, title);
}
});
btn.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String url = et.getText().toString();
//判断输入的内容是不是网址
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);
}
}
Java代码
< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
< TextView
android:id="@+id/TextView_PROM"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
< EditText
android:id="@+id/EditText_PROM"
android:layout_width="fill_parent"
更多精彩
赞助商链接