混合开发在移动开发中很常见,比如qq中的运动,厘米秀等功能都是用网页实现的。
混合开发中一个重要的功能就是网页和原生接口的数据交互,下面将实现一个小demo.
新建一个activity,布局如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.h.learn.WebViewActivity">
<WebView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/my_web_view"
/>
<LinearLayout
android:background="@drawable/webview_bg"
android:layout_weight="1"
android:orientation="vertical"
android:layout_width