2012년 5월 19일

화면이 가로/세로 모드로 전환시 onDestroy() 호출 되지 않게 하기




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);

댓글 없음:

댓글 쓰기