Sheehan, regarding onRetainNonConfigurationInstance(), below is what I am currently doing for my app in progress. I have the feeling I'm overcomplicating it though, I think there's a simpler way; however, this works just fine for me currently.
Sheehan, regarding onRetainNonConfigurationInstance(), below is what I am currently doing for my app in progress. I have the feeling I'm overcomplicating it though, I think there's a simpler way; however, this works just fine for me currently: So in my activity class "RotationMenu. Java": private Object catcher; //lots of non-related code here //directoryList is a returned list of selected directories, that I wish to //retain in the event of an orientation state change.
String directoryList = new StringarrayList.size(); arrayList. ToArray(directoryList); //here, I set the class Object catcher to the directoryList catcher = directoryList; //rest of non-related code //this method is called when the orientation changes (for me, //when I open my Droid's hardware keyboard) public Object onRetainNonConfigurationInstance() { //If I've entered anything into my catcher Object, it will be kept //across orientation changes. Final Object data = catcher; return data; } Now, in my onCreate(Bundle savedInstanceState) method: //We retrieve the stored Object and cast it to a String array final Object recipient = (String) getLastNonConfigurationInstance(); //in case the state changes again before the code that sets the directories is run catcher = recipient; //if there was any stored data, we can now reinstate the list adapter where the //directoryList was originally being used.
If(recipient! = null) { returnedDirectories. SetAdapter(new ArrayAdapter( this.getBaseContext(), R.layout.
Simple_list_item_small, (String)recipient)); } Again, this is how I am doing it currently. If anyone knows of a more efficient method, by all means comment. :).
I'll try and implement this into my own code! Do you know how I can pull chartImageViewLandscape from my /layout-land/main. Xml?
Seems like it is always null! – Sheehan Alam Sep 3 '10 at 22:07 You don't want to actually store the View object, from my understanding, that will cause memory leaks. Instead, store the bitmap or drawable that the ImageView contains, and then set that back to the chartImageViewLandscape View in the onCreate() method.
– kcoppock Sep 3 '10 at 22:10 but I can't even set chartImageViewLandScape because I need to be able to hook it up to the layout via findViewById – Sheehan Alam Sep 3 '10 at 22:11 You shouldn't have to. As long as the layout names are the same, it will look it up by its ID, no matter where you move it. Maybe I am misunderstanding?
– kcoppock Sep 3 '10 at 22:14 /layout-land/main. Xml has only an ImageView and nothing else. /layout/main.
Xml has a listview, and some buttons etc. Hope that clarifies things a bit? – Sheehan Alam Sep 3 '10 at 22:15.
Beside that, nothing else to do. Android will switch by itself. If you have different UI components, you probably want to still declare them in both layouts so that any call to findViewById will not crash your app.
Just make the layout so that they are not displayed (in a FrameLayout, behind the image for example) If you prefer to do it more manually, you need to put an android:configChanges="orientation" in your manifest and implement onConfigurationChanged.
Sounds good. Also, as far as having it download from the internet on changing the configuration goes, you should definitely find a way to store the image in between orientation changes (for one I've done, I used onRetainNonConfigurationInstance() to save an object and getLastNonConfigurationInstance() to restore the image) so that it doesn't try to redownload the image every time it goes from portrait to landscape and vice versa. – kcoppock Sep 3 '10 at 18:51 updated with more details on my problem.
@kcoppock can you show me an example of your onRetainNonConfigurationInstance()? – Sheehan Alam Sep 3 '10 at 19:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.