我正在尝试使用navigation drawer
构建一个标准的简单ArrayAdapter
,但是当点击元素时我需要在抽屉里面加载一些html webView
,这是可能的吗?不知何故?
我正在构建这样的layou
t:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_new_order"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".BaseActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/app_bar" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/activity_content_base" />
</FrameLayout>
</LinearLayout>
<!--place for drawer-->
<FrameLayout
android:id="@+id/navWeb"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="right|end">
<include layout="@layout/drawer_test" />
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
其中layout/drawer_test
是我的cutom layout
答案 0 :(得分:0)
试试这个: -
替换此代码(代码中的正确位置):
<LinearLayout
android:id="@+id/drawer_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_margin="1dp"
android:background="@drawable/rounded_corner"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@drawable/rectangle"
android:orientation="horizontal"
android:weightSum="100">
<ListView
android:id="@+id/drawerList"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:choiceMode="singleChoice"
android:listSelector="@drawable/list_selector" />
<WebView
android:id="@+id/webview"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:background="#888888" />
</LinearLayout>
</LinearLayout>
创建2个drawables,rectangle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff"/>
<stroke
android:width="4dp"
android:color="@android:color/holo_red_light"/>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp"/>
</shape>
和rounded_corner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#ffffff" >
</solid>
<stroke
android:width="4dp"
android:color="@android:color/holo_red_light" >
</stroke>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" >
</padding>
<corners
android:radius="10dp" >
</corners>
</shape>