Reputation: 79
I am in process to create a new android application with EditText component occupying my complete screen
{
<EditText
android:width="fill_parent"
android:height="fill_parent" />
}
I am assigning text to EditText component through setText(getResources().getIdentifier("TextName","string",getPackageName()));
file dynamically according to users choice from options available in Spinner
It is all fine to execute desired output, but when i change my landscape from verticall to horzontal and vice-versa, my application crashes with annoying statement "Unforfunetly, exampleApplication has stopped"
I will be Thankful to any encouraging reply and suitable solution.
Thank you in advance.
Upvotes: 0
Views: 605
Reputation: 2009
So, what's happening is that when you rotate the screen, Android tries to recreate the activity in landscape mode (because you could have provided a landscape layout file).
If you don't want to have a landscape layout specifically, then add this to your <activity></activity>
tag in AndroidManifest.xml
:
<activity
android:name=".SongsActivity"
android:configChanges="keyboardHidden|orientation" <!--This line-->
android:label="SomeLabelName" />
This will rotate the activity without any recreation.
What exactly does this mean? Adding this tag in your activity tells Android that Configuration Changes, if any, will be handled by you explicitly, and the system need not worry about recreation. In response, the system simply rotates the view, which is sufficient in most cases.
I would still suggest that you read more of Android documentation on this. Hope this helps! :)
Upvotes: 1