本实例主要介绍通过WebView实现如何通过网页设计UI(当网页UI请求错误时,怎样给用户返回友好的界面)、如何利用WebView实现下载功能、以及通过cookie实现免登陆功能。
xml布局文件
<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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/id_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_back" />
<TextView
android:id="@+id/id_url"
android:singleLine="true"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="url"
android:textColor="#44000000"
android:textSize="23sp" />
<ImageButton
android:id="@+id/id_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_refresh" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:backgr