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);
    
        }
    }
  • 相关阅读:
    ecshop首页最新评论的调用
    在ECSHOP商品列表页显示每个商品的评论等级和评论数量
    ecshop 系统信息在哪个页面
    ECSHOP去版权_ECSHOP2.7.2去版权方法最新方法
    ECShop 自定义函数以及调用
    ecshop 首页如何调用积分商城里面的的商品
    回到顶部的js代码
    ./flow.php (购物流程)
    C#把字符串转时间格式
    如何将服务端的多个文件打包下载(转)
  • 原文地址:https://www.cnblogs.com/zoro-zero/p/4524670.html
Copyright © 2011-2022 走看看