Двухуровневый список ListView в приложении для Android
Хотите двух (много) уровневый список в приложении Android? — их есть у меня (с).
1) Создаем активность и ложим на неё listView
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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" tools:context="ru.yarteleservice.noc.noc.Form2"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="wrap_content" android:longClickable="false" /> </LinearLayout> </android.support.constraint.ConstraintLayout> |
2) Создаем layout который будет отвечать за отображение наших данных внутри listView
wedwed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="5dp" android:layout_weight="1" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="left" android:padding="5dp" android:text="@string/list_view_txt" android:textColor="@android:color/black" android:textStyle="bold"></TextView> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp" android:text="@string/list_view_txt" android:textColor="@android:color/holo_orange_dark"></TextView> </LinearLayout> |