<pre name="code" class="java">/**
* 加载网页的Activity
*
*/
public class WebActivity extends BaseActivity {
private ProgressWebView webview;
private String url;
private String name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.commom_web);
// ~~~ 获取参数
url = getIntent().getStringExtra("url");
name = getIntent().getStringExtra("name");
// ~~~ 绑定控件
webview = (ProgressWebView) findViewById(R.id.webview);
// ~~~ 设置数据
titleText.setText(name);
webview.getSettings().setJavaScriptEnabled(true);
webview.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
if (url != null && url.startsWith("http://"))
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
webview.loadUrl(url);
}
}
<pre name="code" class="java">/**
* 加载网页的Activity
*
*
*/
public class WebActivity extends BaseActivity {
private ProgressWebView webview;
private String url;
private String name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.commom_web);
// ~~~ 获取参数
url = getIntent().getStringExtra("url");
name = getIntent().getStringExtra("name");
// ~~~ 绑定控件
webview = (ProgressWebView) findViewById(R.id.webview);
// ~~~ 设置数据
titleText.setText(name);
webview.getSettings().setJavaScriptEnabled(true);
webview.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
if (url != null && url.startsWith("http://"))
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
webview.loadUrl(url);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include layout="@layout/include_title" />
<com.nmbb.ui.widget.ProgressWebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>