What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by MrSnowflake » Fri, 24 Apr 2009 21:01:27 GMT


Sponsored Links
 Why do so much people avoid the destoying and recreation of Activities
on orientation change. It's there to make the switch to a different
orientation easier, because it automatically loads the correct
resources. To be honest, I don't fully understand the whole recreation
of Activities neither, as it would take a lot of time to recreate the
activity and loading (and saving the instance state too) the instance
state could take a long time too. But I bet those intelligent Google
people have good reasons, that's why I follow their idea.

I don't know how to refresh your UI. If you mean by refreshing:
loading the appropriate resources to get the correct layout for the
current orientation, then you need to destroy and recreate the
Activity. That's why the system does this by default!

You should save all current state specific information in
onSaveInstancestate() (or what is it called, I forgot, it's a couple
of weeks ago I did some Androiding :) ) and reload it in
onRestoreInstancestate(). And well, all this stuff is in the docs so
you can take a look there :).



--~--~---------~--~----~------------~-------~--~----~



What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by Wang He » Mon, 27 Apr 2009 10:56:20 GMT


 Is here anybody knows the right way?
Still waiting ...

BRs
He



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by Wang He » Mon, 27 Apr 2009 16:26:10 GMT


 1. I don't want to  recreate the activity when switching at Land &
Port, many runtime data I don't want to save and reload;
2. So I use onConfigurationChanged() facility, but I have UI for Land
& Port, What I do now is:
    public void onConfigurationChanged(Configuration newConfig) {
           setContentView() again as onCreate();
          run findViewById()s as handlers will lost after
setContentView();
          setListeners for UI widgets as they will lost also;
  }

3. Is the way right I did in 2?

BRs
He





--~--~---------~--~----~------------~-------~--~----~



What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by MrSnowflake » Mon, 27 Apr 2009 19:52:06 GMT


 You don't have to load and save that stuff, you can put references to
your runtime data in a custom class and return that in
Activity.onRetainNonConfigurationInstance()  (http://
developer.android.com/reference/android/app/
Activity.html#onRetainNonConfigurationInstance()) and get it in
Activity.getLastNonConfigurationInstance().






--~--~---------~--~----~------------~-------~--~----~



What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by quakeboy » Tue, 28 Apr 2009 17:17:00 GMT


 You might want to take a look at setRequestedOrientation if u want
to ..



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Can Android be ported to other mobiles..??????(couple of questions)

hi ,
---- Can android be ported to other mobiles already  in use...? or we
need to buy the mobiles provided for only for them ??
---- What mobiles are supporting android at the moment..?
---- I have seen many videos in which they gave demos on android ...
can anyone tell me wat mobiles are they using
and when are they coming out?
---- What are the requirements for a mobile to port android into it..?
if it can be...


tanx in advance ....

--~--~---------~--~----~------------~-------~--~----~

2. Hello Android crashes

I just installed Android (WinXP) for Eclipse (Europa 3.3.2).  I was
following the 'Hello Android' example in the getting started
documentation.  Everything went great until I tried to debug it.  I
saw the emulator come up briefly and then my computer rebooted.  The
compter is a Pentium D 3GHz with 1G of ram.  Eclipse and Android are
installed on an external USB 80G hard drive with 55G available.  Drive
C is a 100G hard drive with 70G available.  I've done a little Java
developing on this setup (I'm primarily a C++/MFC programmer).  Any
guesses?

--~--~---------~--~----~------------~-------~--~----~

3. Parse JSON

4. Got the MapView loading, but the map is blank?

5. Vote for invitation for "Plusminus" to the HTC/T-Mobile announcement on Sept 23.

6. List<T>

7. Bug in focus handling between WebView and ListView