0

I have been trying to make an application, and since I am new to android development I am stuck with this small problem. The application which when opened shows this layout as the first page.First page

Then after choosing the content from the list view a fragment transaction occurs and this page is opened. Description of the selected list view item

I have used fragments because I have used drawer layout and tabbed layout using action bar sherlock theme.

The problem I am facing is after the screen is rotated the previous fragment is loaded, i.e. it takes me back to the list view page from the information page. Taken back to previous fragment

I have read that we have to save and load the state of the application but as I am new to this I don't know how to implement it. Please help!!!

ganapathy
  • 1,407
  • 3
  • 13
  • 20
  • 1
    Does this help? http://stackoverflow.com/questions/17341295/retaining-data-on-screen-orientation-change – AndyFaizan Mar 14 '14 at 18:34
  • so to save the list view whose content is obtained from the database I will have to save the instance of the list view and then load it in the onCreate method – ganapathy Mar 14 '14 at 18:38
  • Yes. That is what the answer states. Saving all views and then retrieving them later. – AndyFaizan Mar 14 '14 at 18:41
  • Do we always have to create separate layouts for the landscape and portrait orientations – ganapathy Mar 14 '14 at 18:45
  • Yes well usually since you want the views aligned according to the orientation. If you want to save time, you could just lock the orientation. – AndyFaizan Mar 14 '14 at 18:47
  • Ok thanks I will try this out :) Is there any special naming convention that i have to follow while creating layouts for the landscape mode? – ganapathy Mar 14 '14 at 18:49
  • This will help - http://stackoverflow.com/questions/2124046/how-do-i-specify-different-layouts-for-portrait-and-landscape-orientations – AndyFaizan Mar 14 '14 at 18:52
  • Suppose I have used relative layout in my portrait file and I copied the same file to layout-land, will the device automatically recognize the layout and fit it according to the size of screen or will I have to change layout specifications in the XML file of landscape orientation – ganapathy Mar 14 '14 at 18:59
  • It actually doesn't work that way. Read about it http://stackoverflow.com/questions/14842847/android-positioning-buttons-when-turned-from-portrait-to-landscape. Sorry for posting links. Explanations would take a long time :P – AndyFaizan Mar 14 '14 at 19:04
  • @AndyFaizan No problem :) Actually while developing another application I was stuck with a similar problem in which after the change of screen orientation the buttons would look distorted i.e one button would overlap another button. In that application too I was using relative layout and a scroll view. But the scroll view wasn't working. I tried both the ways scroll view inside relative layout and relative layout inside scroll view. Is there any method which can solve this problem – ganapathy Mar 14 '14 at 19:48
  • You'll have to put up a question with code for that (but do your research before posting) :) – AndyFaizan Mar 15 '14 at 06:02

0 Answers0