Sunday, 15 July 2012

How to Filter JSON object in Android in accordance with another value of object? -



How to Filter JSON object in Android in accordance with another value of object? -

i've json object this:

json object

{ "31": { "basic": { "node_id": "31", "title": "test", "alias": "test", "description": "test", "site_id": "151336557", "node_type": "7", "privacy": "7", "deleted": "0", "status": "1", "created_date": "1379169518", "updated_date": "1379169518", "created_by": "140513626519686828", "updated_by": null, "readable_date": "14th sep, 2013" }, "meta": { "forum_id": "61" }, "comments": { "count": 1 }, "likes": { "count": 0 }, "tags": [], "node_id": "31" }, "32": { "basic": { "node_id": "32", "title": "testing discussion", "alias": "testing-discussion", "description": "testing", "site_id": "151336557", "node_type": "7", "privacy": "7", "deleted": "0", "status": "1", "created_date": "1379493816", "updated_date": "1379493816", "created_by": "140513795022034166", "updated_by": null, "readable_date": "18th sep, 2013" }, "meta": { "forum_id": "65" }, "comments": { "count": 1 }, "likes": { "count": 0 }, "tags": [], "node_id": "32" } }

and code want object:

arraytemplist = new arraylist<feeditem>(); for(int x=0;x<feeditems.size();x++) { int currentnodetype =feeditems.get(x).getnode_type(); if (currentnodetype!=0 && currentnodetype==nodetype) { arraytemplist.add(feeditems.get(x)); log.d("cem", arraytemplist.tostring()); } else{ listadapter = new feedlistadapter(this, feeditems); listview.setadapter(listadapter); listview.setemptyview(findviewbyid(r.id.empty)); } } listadapter = new feedlistadapter(this, arraytemplist); listview.setadapter(listadapter); listview.setemptyview(findviewbyid(r.id.empty)); }

i not able display view filtered data. can log info not able display it.

the whole code here http://pastie.org/9662511

first, should not set adapter every iteration. secondly, should phone call notifydatasetchanged method of baseadapter refresh info displayed in list view.

arraytemplist = new arraylist<feeditem>(); for(int x=0;x<feeditems.size();x++) { int currentnodetype =feeditems.get(x).getnode_type(); if (currentnodetype!=0 && currentnodetype==nodetype) { arraytemplist.add(feeditems.get(x)); log.d("cem", arraytemplist.tostring()); } } listadapter = new feedlistadapter(this, arraytemplist); listview.setadapter(listadapter); listview.setemptyview(findviewbyid(r.id.empty)); listadapter.notifydatasetchanged() }

android json

No comments:

Post a Comment