androidactivity与webview结合

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- header page -->

<LinearLayout
android:id="@+id/mian_header"
android:layout_width="match_parent"
android:layout_height="90dip"
android:background="@color/main_header_bg_new"
android:orientation="vertical" />
<!-- body page -->

<LinearLayout
android:id="@+id/mian_body"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="@color/main_body_bg_new"
android:orientation="vertical" />

</LinearLayout>

activity and webview

1.先定义一个 UI activity (包含webview区域).
2.UI activity 的 java 代码中定义 webview区域的替换代码,将模板代码替换为webview(就类似于div 中的添加内容,DIV容器本身没有内容,只是站位作用),实现回退功能(不显示的话,比较丑啊).
FragmentTransaction ft = manager.beginTransaction();
XXXXX
XXXXX
XXXXX
ft.commit(不要忘记commit,否者没有效果);
3.在WEBView进行相关操作(此处单独扩展,不在详述)。
4.在UI的其他显示部分,实现点击空白回退功能或者点击home回退功能。
5.注意异常的捕获,处理,和友好的提示。

String carNumber = arrayData[0].substring(arrayData[0].lastIndexOf(",") + 1).trim();
FragmentTransaction ft = manager.beginTransaction();
ft.replace(R.id.mian_body, webFragment, "WebViewFragment");
Bundle bundle = new Bundle();
bundle.putString(OvalConstant.TAG_MODEL_KEY, OvalConstant.TAG_CUSTOMER_VALUE);
bundle.putString(OvalConstant.SHARED_PLATENO_ZH_KEY, bodySearchTextView.getText().toString());
if ("-999".equals(arrayData[3].trim())) {
bundle.putString(OvalConstant.TAG_PARAMS_KEY, "PLATENO=" + carNumber);
} else {
bundle.putString(OvalConstant.TAG_PARAMS_KEY, "PLATENO=" + carNumber + "&CUSTOMERCODE=" + arrayData[3].trim());//

时间: 2024-08-05 13:44:38

androidactivity与webview结合的相关文章

Appium 微信 webview 的自动化技术

最近好多人问微信webview自动化的事情, 碰巧我也在追微信webview的自动化和性能分析方法. 先发出来一点我的进展给大家参考下. 此方法用于Android平台, iOS请自行解决 微信的设置 用微信打开debugx5.qq.com, 这是个微信的x5内核调试页面. 你可以在任何聊天窗口内输入这个网址. 并打开它. 勾选"是否打开TBS内核Inspector调试功能" 使用ChromeDriver编写测试用例 首先安装ChromeDriver从官方下载或者从你的appium的安装

10.3.3 WebView的几个常见功能

当前主流的开发模式是"WebView+ProgressDialog" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_paren

Android WebView 开发教程

1.WebView的使用 (a). 创建WebView的实例加入到Activity中 WebView webview = new WebView(this); setContentView(webview); 或者在xml中配置WebView <Webview android:layout_width="match_parent" android:layout_height="match_parent" > </Webview> (b). 访

WebView使用详解(三)——WebChromeClient与LoadData补充

前言: 我不会忘了我 忘了我曾说过一定会得到的梦想 --<老大>小柯 相关文章 1.<WebView使用详解(一)--Native与JS相互调用(附JadX反编译)> 2.<WebView使用详解(二)--WebViewClient与常用事件监听> 一.WebChromeClient 1.概述 (1). 与WebViewClient的区别 很多同学一看到这里有Chrome,立马就会想到google 的Chrome浏览器:这里并不是指Chrome浏览器的意思,而是泛指浏览

Android WebView loadData读取两次才能显示的问题

webview.loadDataWithBaseURL(null,result,"text/html", "utf-8", null); 使用loadDataWithBaseURL替代loadData 参考网址:http://stackoverflow.com/questions/17501860/had-to-load-data-twice-to-make-webview-refresh-in-android

Android中webview和js之间的交互(转)

http://www.cnblogs.com/leizhenzi/archive/2011/06/29/2093636.html 1.android中利用webview调用网页上的js代码. Android 中可以通过webview来实现和js的交互,在程序中调用js代码,只需要将webview控件的支持js的属性设置为true,,然后通过loadUrl就可以直接进行调用,如下所示: mWebView.getSettings().setJavaScriptEnabled(true); mWebV

【WebView】带加载进度条的WebView及Chrome联调

先看效果图: 看到顶部蓝色的进度条了. 原理:用到了 android.webkit.WebChromeClient中的onProgressChanged,而android.webkit.WebViewClient是没有这个方法的.所以普通的WebView是无法实现进度条的. 下面直接上干货: /** * ProgressWebView * * @author lif * * */ @SuppressWarnings("deprecation") public class Progres

Android一组WebView的随机,顺序,倒序加载

写了个应用,实现了一组WebView的顺序,倒序,和随机加载.之中使用了延时,为什么要使用呢?请看下图: package com.zms.csdngo; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiManager; i

屏蔽电信流氓广告造成的诡异的问题--Android WebView 长时间不能加载页面

发现在家里的时候用Android App里的WebView打开网站很慢,会有十几秒甚至更长时间的卡住. 但是在电脑上打开同样的网页却很快. 查找这个问题的过程比较曲折,记录下来. 抓取Android网络数据 为了调试这个问题,首先要抓取Android的网络包数据.开始时,是想用Wireshark来抓包的,但是很麻烦,tcpdump在手机要root权限. 于是转换思路,能不能在Android上设置代理,来抓包? 但是fiddler没有linux版本,于是转用BurpSuite了. 设置Androi