zoukankan      html  css  js  c++  java
  • android webview使用介绍

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:orientation="vertical"
        tools:context="mydemo.mycom.demo2.WebViw">
    
        <ScrollView
            android:layout_weight="1000"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    
    
            <WebView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/wv">
    
            </WebView>
    
            </ScrollView>
        <EditText
            android:hint="webview地址"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="http://192.168.1.1:100/ProductInfo/Detail/E618923F06B644BFAA86AB274AF02358"
            android:id="@+id/et_webview_url"/>
        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/btn_load_webview"
            android:text="加载内容"/>
    
    
    </LinearLayout>
    package mydemo.mycom.demo2;
    
    import android.support.v7.app.ActionBarActivity;
    import android.os.Bundle;
    import android.text.TextUtils;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.webkit.WebView;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;
    
    
    public class WebViw extends ActionBarActivity implements View.OnClickListener {
    
    
        private WebView wv;
        private EditText et_webview_url;
        private Button btn_load_webview;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_web_viw);
    
            wv = (WebView)findViewById(R.id.wv);
            et_webview_url = (EditText)findViewById(R.id.et_webview_url);
            btn_load_webview = (Button)findViewById(R.id.btn_load_webview);
            btn_load_webview.setOnClickListener(this);
    
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.menu_web_viw, menu);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            int id = item.getItemId();
    
            if (id == R.id.action_settings) {
                return true;
            }
    
            return super.onOptionsItemSelected(item);
        }
    
        @Override
        public void onClick(View view) {
            String path = et_webview_url.getText().toString().trim();
            if(TextUtils.isEmpty(path))
            {
                Toast.makeText(this,"webview路径不能为空",Toast.LENGTH_SHORT).show();
                return;
            }
    
            wv.loadUrl(path);
    
        }
    }
  • 相关阅读:
    超级好用的excel导出方法,比phpexcel快n倍,并且无乱码
    PHP生成随机数;订单号唯一
    php判断检测一个数组里有没有重复的值
    修改git 提交的用户名和用户Email命令
    利用 PHP CURL zip压缩文件上传
    Linux 重启 PHP-FPM 命令
    Postgresql 时间串转换格式
    rollup node.js 打包工具
    PHP正则表达式提取html超链接中的href地址
    解决Ubuntu系统下 mysql 远程连接失败的问题 ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xx.xx' (110)
  • 原文地址:https://www.cnblogs.com/zoro-zero/p/4524670.html
Copyright © 2011-2022 走看看