Reacting to Configuration Changes
As a further alternative, you can have your application listen for events that would cause a restart - like orientation and keyboard visibility changes -- and handle them within your Activity.
Start be adding the android:configChanges node to your Activity's manifest node
android:configChanges="keyboardHidden|orientation"
Then within the Activity override the onConfigurationChanged method and call setContentView to force the GUI layout to be re-done in the new orientation.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.myLayout);
댓글 없음:
댓글 쓰기