Should I use a ListView?
In order to enter information into my database, I'm currently using a scrollview (with a table layout, iirc). However, loo开发者_如何学编程king at the api demos, I'm wondering if I should switch to a listview. It seems a bit of a strange way to do it, as I'd have to hard code the numbers of items, it would all have to be in java rather than xml, and each one would need a separate onclicklistener, but as far as layout is concerned it sounds like by far the easier to maintain. (I'm considering the switch now as I'm doing a major rewrite anyway, so now would be a good time)
Anyone have any opinions that they wouldn't mind sharing? Would this be a horrific abuse of a listview, and should I stick with what I have? Or should I move to something that I can much more easily theme later on (my current layout is pretty ugly)?
I think of ListView
as being the exact opposite.
- You don't have to hard code list items: they come from various adapters like
CursorAdapter
andArrayAdapter
. - You can use a single
OnItemClickListener
to handle the click events for all of your items.onItemClick
provides you with the position of the item that was clicked. - Even your presentation can be dynamic, since you can easily switch out a
GridView
for theListView
later.
I would recommend trying ListView
; it will give you another tool to work with and inform your design decisions in the future.
精彩评论