0

i have following JSON format

{
"listing": {

    "attribute": [{
        "name": "brand",
        "data": [{
            "value": "brand with subtitle"
        }, {
            "value": "Brand2"
        }, {
            "value": "Samsung"
        }]
    }, {
        "name": "price",
        "data": [{
            "value": 12
        }, {
            "value": 1499
        }]
    }, {
        "name": "color",
        "data": [{
            "value": "Red"
        }, {
            "value": "Green"
        }]
    }, {
        "name": "size",
        "data": [{
            "value": "XXXL"
        }, {
            "value": "L"
        }]
    }]
  } 
}

In above format there are two array attibute and data. So i for attribute array includes multiple name which i want to display in listview so i done this task successfully see below image

enter image description here

but inside that there are data array list for particular name and that arraylist value also i want to display in right side listview means if i click on brand at that time brand's value will be shown in right side listview . i done following code for left side listitem

if (mGetProductListing.getListing().getAttribute().size() > 0) {
                    mainMenuDataArrayList = getData();
                    if (mainMenuDataArrayList.size() > 0) {
                        mFilterCateAdapter = new FilterCateAdapter(ActivityFilter.this, mainMenuDataArrayList);
                        mListViewLeft.setAdapter(mFilterCateAdapter);
                        mFilterCateAdapter.setSelectedIndex(0);


                    }
                }

But how can i list out right side list item dynamically as per choose category ? your all suggestions are appreciable

Harshal Kalavadiya
  • 2,412
  • 4
  • 38
  • 71
  • Possible duplicate of http://stackoverflow.com/questions/2250770/how-to-refresh-android-listview. In addition, you can write a custom ListView Adapter and then simply pass the JSONArray object of the corresponding left side list view selection to an update function in the Adapter wherein you update the content and follow steps in the mentioned answer. – Obscure Geek Mar 28 '16 at 04:54
  • Obscure Geek i m not getting what you say, i have dynamic main category and also its subcategory so how can i handle it position wise? – Harshal Kalavadiya Mar 28 '16 at 05:08
  • Do you want Custom Adapter for that or ArrayAdapter? You would need an XML file to inflate the view for each item list in your Adapter. Ensure to add `ids` so you can reference it for the assigning of value. So provide this first. 1. XML for Inflation of the item list. 2. Custom adapter or ArrayAdapter. – Aizen Mar 28 '16 at 05:15
  • Aizen: i implemented it with CustomAdapter – Harshal Kalavadiya Mar 28 '16 at 05:17
  • Are you asking about changing the data of the list and calling notifyDataSetChanged()? – Nanoc Mar 28 '16 at 05:51
  • Nanoc i m asking about change list item value in right side as per click left side list item, **Both list item value is dynamic** – Harshal Kalavadiya Mar 28 '16 at 06:14

1 Answers1

0
    private List<Attribute> attributeList;
    private List<AttributeData> dataList;

    initialise both lists in constructor of adapter.

    This list contains your json response under tag "attribute" that has "name" and "data"

    In your custom list adapter under getView() method, 
    convertView.setOnClickListener(new View.OnClickListener() {

    @Override
                public void onClick(View v) {
                   if(attributeList.get(position) != null && !attributeList.get(position).getDataList().isEmpty) {
                      dataList.addAll(attributeList.get(position).getDataList);
//Now pass dataList list to the fragment on the right.

                   }

     }
            });