我在我的应用程序中使用嵌套的listview作为下面的xml文件。我从Json字符串获取数据:
{
"Result": [{
"First Data": [
{ "Name": "Ajay" },
{ "Address": "xyz" },
{ "Age": "12" },
{ "Mobile": "5489927" }
]
}, {
"Second Data":[
{ "City":"abc" },
{ "State":"fdf" },
{ "Town":"abc" },
{ "Street": "xyz" }
]
},
{
"Third Data": [
{ "Collage": "Yes" },
{ "School": "Yes" },
{ "University": "Yes" }
]
}]
}
我想在firstlist.xml的textview中显示“First Data,Second Data,Third Data”字段,并将相关数据显示在内部listview中。
firstlist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/exText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/sublist"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
secondlist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/subtext"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>