+1 to this - it is exactly the path I took.  It had the advantage too,
that when I added in an offline cache, I could reuse the ArrayAdapter
to display data from either JSON or SQLite.

Plus it makes the code a whole lot more readable.

On Sun, Feb 27, 2011 at 09:09, Rishi Kumar <reeesh...@gmail.com> wrote:
> Can I suggest that you separate the JSON parsing and the List View display
> into separate components of your code?  I'd recommend that you do a
> translation between JSON and your domain model (Java beans) and then use
> those objects to interact with your Array Adapter.  That way you can
> separate the implementation details of data sourcing and display into
> separate concerns.   This will also shield you from changes in the source
> JSON structure as well.
> If you go down this path, you can then write your own ArrayAdapter that
> works off your business objects.   e.g.  public class MyArrayAdapter extends
> ArrayAdapter<MyBusinessObject> ....
> In this object, you can store a private member points to the list of
> business objects.  private List<MyBusinessObject> list;
> Then its just a matter of pulling out the right object when the view is
> called and then mapping that to the fields that are in your list view.
>
> Hope that helps.
> -rishi
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
http://www.opgenorth.net

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to