albert albert - 2 months ago 8
Android Question

How to add header in Listview using json

I am using listview and parsing data and it display properly.but i want to add filterName as a header in my listview from same url.can any one tell me how to achive that.Thanks in advance.

JSON RESPONSE

[
{
"filterID": "3",
"filterName": "Food Type",
"getParam": [
{
"paramId": "P102",
"paramName": "Treats"
}
]
},
{
"filterID": "5",
"filterName": "Pet Size",
"getParam": [
{
"paramId": "P14",
"paramName": "Large"
}
]
},
{
"filterID": "7",
"filterName": "Conditions / Health Benefits",
"getParam": [
{
"paramId": "P60",
"paramName": "Dental"
}
]
},
{
"filterID": "99999",
"filterName": "Manufacturer",
"getParam": [
{
"paramId": "M1009",
"paramName": "Dentipet"
},
{
"paramId": "M1024",
"paramName": "KONG"
},
{
"paramId": "M1027",
"paramName": "Mavlab"
},
{
"paramId": "M1035",
"paramName": "Nutro"
},
{
"paramId": "M1044",
"paramName": "Virbac"
}
]
}
]

Answer

These are called sections, and there are thousand of examples available already. One example http://stacktips.com/tutorials/android/listview-with-section-header-in-android explained in detail.