I am a beginner in android programming, now i am working on an android application which displays the data in a sort order by default and also provides a search facility. For this i have written an activity called search that will search the contents and displays in a listview. My problem is when i rotate the device the onCreate method of the Activity class is called even after overridding the onConfigurationChanged method. I had also done the following changes in the manifest file to invoke the onConfigurationChanged method.
<activity
android:name=".Search"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="sensor" >
</activity>
my activity class snippet as follows.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("HERE AT ONCREATE");
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
System.out.println("HERE AT ON CONFIGURATION CHANGED");
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.search_port);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.search_land);
}
}
So the output while rotating the device will be
HERE AT ON CONFIGURATION CHANGED
HERE AT ONCREATE
I dont want to get the ONCREATE method called while rotating the device. Please help me to solve this issue. I am using Android 2.2 SDK with samsung Galaxy Tab (7 inch display).
No comments:
Post a Comment