zoukankan      html  css  js  c++  java
  • Android中WebView的简单使用

        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" />

  • 相关阅读:
    博客地址
    Version 1.4.2_03 of the JVM not suitable for this product.解决
    http请求(一) 工具
    Service 的两种启动方法和区别
    软件开发过程应该采用集中优势兵力各个击破
    架构感悟
    嵌套事务模版
    软件行业对人才的依赖
    使用SQL Server 2005 新的语法ROW_NUMBER()进行分页的两种不同方式的性能比较
    架构设计中的分层与分区
  • 原文地址:https://www.cnblogs.com/xiaoyao095/p/4120855.html
Copyright © 2011-2022 走看看