public Button btnPay; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btnPay = (Button) findViewById(R.id.btnPayfor); btnPay.setOnClickListener(new BtnPayMoneyListener()); } private final class BtnPayMoneyListener implements View.OnClickListener { @Override public void onClick(View v) { //直接跳转浏览器页面 // Intent pay = new Intent(Intent.ACTION_VIEW, Uri.parse(payUrl)); //页面在WebView中嵌套 String payUrl = "http://www.baidu.com"; Intent pay = new Intent(MainActivity.this, PayMoneyActivity.class); //Intent传值 pay.putExtra("url", payUrl); startActivity(pay); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.money); Intent itent = getIntent(); String url = itent.getStringExtra("url"); web = (WebView) findViewById(R.id.vv);
WebSettings seting = web.getSettings();
// 设置WebView属性,能够执行的脚本
seting.setJavaScriptEnabled(true);
// 设置可以访问文件
seting.setAllowFileAccess(true);
// 设置支持缩放
seting.setBuiltInZoomControls(true);
// 加载需要显示的网页
web.loadUrl(url);
}
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />