开发者

Binding data in Android

I have following scenario. There is OrderHeader and OrderDetail tables in SQLLite database. I have Activity where I want to display that data. There is number of fields...

The way I see it - it has to be like this:

  1. Get data from my content provider (I have it).
  2. Get ordinals for columns in cursor.
  3. Get values from cursor and format/assign them

Like I said - there is MANY fields and writing this kind of code (especially #1 and #2) very tedious and boring :)

So, I've got this idea.. Since my data comes in as JSON to begin with (from web) - I can store original JSON presentation in database along with parsed-out data and when I need to bind - all I need is to query table for this column and deserialize with GSON. This way - #1 and #2 will be 3 lines instead of many. And I will work w开发者_StackOverflow中文版ith POJO...

Does that sounds good or there is natural nice way to bind views to data from database?


Use a ListView and a SimpleCursorAdapter (or extend it).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜