androidactivity與webview結合

來源:互聯網
上載者:User

標籤:

 

 

 

 

 

 

 


<?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());//

androidactivity與webview結合

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.