<ListView 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:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#cccc"
tools:context=".NavigationDrawerFragment" />
У меня есть, что, как fragment_navigation_drawer.xml, но я хочу, чтобы иметь заголовок, просто простой ImageView или что сложная вещь с именем, электронная почта, CircleView ..Как я могу добавить заголовок в Ящиком
Как я могу это изменить?
Этот файл: fagment_main.xml
<RelativeLayout
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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">
<TextView android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
This file: fragment_navigation_drawer.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NavigationDrawerFragment">
<ImageView
android:id="@+id/my_header_image_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/simple_image_ok" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#cccc" />
</LinearLayout>
Thisfile: activity_main.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity">
<FrameLayout android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment android:id="@+id/navigation_drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:name="t9200.laurentiu.com.dti200t9.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Those are my xml files.. i hope you can help me :D
03-26 18: 34: 02,674 5431-5431/t9200.laurentiu.com.dti200t9 Х/AndroidRuntime: неустранимое: Основной Процесс: t9200.laurentiu.com.dti200t9, PID: 5431 java.lang.RuntimeException: Не удалось запустить активность ComponentInfo {t9200.laurentiu.com.dti200t9/t9200.laurentiu.com.dti200t9.MainActivity}: android.view. InflateException: двоичная строка XML-файла # 19: ошибка раздувания фрагмента класса на android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2395) в android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2453) в android.app.ActivityThread.access $ 900 (ActivityThread.java:173)
и он продолжается.
Как использовать? –
Вы можете определить свой собственный файл макета для заголовка как header.xml, а затем раздуть его, а выше код добавит его в виде заголовка в виде списка. – ksarmalkar