Issue
I'm building an app where you can edit a detailspage. Right now I set the visibility to GONE and to VISIBLE because all the Views (for showing and for editing) are in the same xml file. That makes more than 80 views, so I got a Lint message that this causes bad performance.
My Question is cann I use ViewFlipper (and is it possible to use two xmls for this) or do I better make use of two Fragments?
(fyi: I am also planning a animation between showing and editing, if that changes what I better do)
thx in Advance
Solution
You do not need either: a ViewFlipper or two fragments introduce unnecessary complications. I would separate showing and editing on different layouts (one XML file for each), and construct a different activity with each layout. When the user clicks on "edit" start the new activity (with an intent) and go to the edit screen. Then after saving the data just finish()
the activity.
That is what we do, and it works great! Sometimes the "easy" solution is the best one, as in this case.
As to the animation part, there are already great answers here on Stack Overflow, such as here or here.
In case you want to keep the ActionBar while you animate between show and edit, two fragments would seem like the way to go. You can also have two layouts and inflate them independently, so that you don't accumulate so many views in one layout. Keep in mind however that (unless you create the ActionBar and fragments yourself) you will be limiting yourself to Honeycomb 3.0 and beyond.
Answered By - alexfernandez
Answer Checked By - Cary Denson (JavaFixing Admin)