title: Best Practice activity- switching and view- changing in android
body: <p>I am still searching for the best solution howto use a layout with a menu and a toolbar and inflate or start activities in android. My question may sound confusing, but im trying to explain it in an example.</p>
  
  <p>Lets say im programming an android app (surprise.. i really do)</p>
  
  <p>My app can do following:</p>
  
  <ol>
  <li>User can log in [3] or register [2]. If he logs in, a new activity starts and his dashboard will be shown. If he registers: an activity for the registrationprocess starts.</li>
  <li>Registrationprocess: user puts in his desired username and password and presses a button to accept. His data will be formvalidated and if valid, a new activity starts where he can choose his settings. Backbutton works and data can be passed to the new activity. After the last registrationwindow data will be saved and dashboard started. Starting new Activities is fun!</li>
  <li>Now THATS where it gets complicated. Dasboard has an 'actionbar'(top) and a 'toolbar' (bottom, like tabs). So everything should be viewed in the middle part of the viewport(from now called main view). No more activity switching :(, tho. 
  Currently each tabclick removes all views from the main view and adds its new view. Look great, can be animated and works like a charm. Except: its currently not dynamic.</li>
  </ol>
  
  <p>So... i don't know how to solve it the best way. For example: i fetch data from a webservice, create a listview out of it and it's extending listactivity. This activity i can't start but this data need to be put into the main view. How can i do it the best way?
  And is it efficient?</p>
  
  <p>I'm practicing and it's actually my first small discussion i want to start. So... FIGHT! ;)</p>
  
  <p><strong>UPDATE:</strong>
  I've seen an interesting way to start activities and get results.
  <a href="https://stackoverflow.com/questions/3436970/launching-activity-through-intents/5605602#5605602">Launching activity through intents</a>
  . Is it possible to insert new/ update views after activity started? I would then generate my results in a separate activity. Update the view. Return back to 'dashboard' and load the view that was just updated. Possible? Or inefficient? And how can i update a view out of another activity? There is so much i need to learn :/</p>
  
  <p><strong>UPDATE2:</strong>
  A good example of an app that has done it: Google+
  Too bad i don't have their sourcecode ;)</p>
  
  <p><strong>UPDATE3:</strong>
  What is best?</p>
  
  <ul>
  <li>load a new activity, disable animation and set selected toolbox tab +
  disable backbutton functionality</li>
  <li>startActionForResults, fetch results and update current view (still don't really know how that would be possible)</li>
  <li>viewFlipper onflip changing+updating data in flipped view.</li>
  </ul>
  
  <p>I still don't know any efficient solution. Or am i missing something essential? I've just finished my ListActivity to fetch data from my webservice. But it still runs in a separate activity. How can i implement it into my "main view" now? Ofcourse... i could set a list my custom adapter. But currently im updating and fetching data from the server when i create the listactivity.</p>
  
  <p>Im afraid this could be the only answer i'll get: <a href="https://stackoverflow.com/questions/4107204/embed-external-intent-in-main-activity">Embed external Intent in main Activity</a></p>
  
  <p><strong>UPDATE4:</strong> I'm trying something.
  Based on nininho's answer (thank you!) im trying the following approach:</p>
  
  <ol>
  <li>Start Dashboardactivity and create a ViewFlipper.</li>
  <li>Each Toolbarclick represents a certain ViewFlipper page.</li>
  <li>Each Page has a Listadapter implemented and shows different results (different webservice queries). (ListView, GridView, with profileimage, without profileimage)</li>
  <li>On Toolbarclick start AsyncTask or Service and notify List in current Page that data has changed. (ofcourse IF data has changed). Switch to page that was clicked.</li>
  <li>Implement updatefeature. On scroll to bottom of list = fetch more data and add it. Update other lists automatically after 5min. or update list on update-button click.</li>
  </ol>
  
  <p><em>PROs so far</em>: Backbutton standalone for whole activity. Page-flip-animation possible. Async updating of lists and still possible to switch to another list.</p>
  
  <p><em>CONs:</em> ... someone has any? What about efficiency of such an approach? Does the ViewFlipper carry all the information so the performance would go down or does the viewflipper recycle its Views (like ListView)? </p>
  
  <p><strong>UPDATE5:</strong>
  If i have some time i will make everything here more read- and discussable. Don't be mad at me for reading my rubbish ;)</p>