roxrook
roxrook

Reputation: 13853

How to handle ListView in this situation Android?

I ran into the situation that I need a way to edit the data of list-view item from another activity. I can handle the click event on each item, then edit it on the fly. However, I still prefer to handle all the editing in a separate activity. My listview item is customized from BaseAdapter. Here is my main page, enter image description here

Each item within the ListView, contains two other TextView. When the I hit the menu setting, it will go to another activity where I can edit and update the information:
enter image description here

I'm currently having two solutions in mind. Either retrieving data from the previous activity and update the whole ListView (which I think it's kinda expensive in the case user just edit one item). Or I can just get rid of the ListView and create a bunch TextView in the xml, by doing this I can just reference to each TextView by their id. So my question is, which way is preferred in this case? Any suggestion would be greatly appreciated.

Upvotes: 0

Views: 203

Answers (3)

rDroid
rDroid

Reputation: 4945

Use text views instead. List View code has been optimized for large amounts of data only and not recommended for small data.

Upvotes: 0

Kevin Galligan
Kevin Galligan

Reputation: 17292

Your ListView is displaying Email, Name, Headline, etc? That should be a fixed XML layout with TextView entries, I think. ListView is for variable numbers of elements. You CAN implement it with a ListView, but I wouldn't.

However, your concern about updating the whole list being overkill, I wouldn't worry about that either. You're talking about 7-10 fields. The amount of time Android needs to run through its lifecycle and display everything will dwarf you updating a few fields.

Upvotes: 1

500865
500865

Reputation: 7120

You can use SharedPreferences for this. You can create a wrapper class through which you can access the preferences.Thats the usual way to go about solving these kind of problems. You can check this for details.

You can have it as a variable in your application class, so that you can access that in a global context.

Upvotes: 1

Related Questions