Android change in view - Button state gets reset?

No, you are using the button in the right way The thing what you are seeing is "configuration change". When you are tilting your device, Android recreating your activity and recreating all it's views (so, they getting default captions as them described in XML) You need to do the disable configuration changes for your Activity. To do so, add the following to your manifest's activity tag: android:configChanges="orientation|keyboarddden It is not suitable, if you have different layouts for landscape and portraint orientations, when you need to handle the configuration changes by overriding onSaveInsatnceState method of your Activity, save a state there and then use it in onCreate method See this article for further explanation.

No, you are using the button in the right way. The thing what you are seeing is "configuration change". When you are tilting your device, Android recreating your activity and recreating all it's views (so, they getting default captions as them described in XML).

You need to do the disable configuration changes for your Activity. To do so, add the following to your manifest's activity tag: android:configChanges="orientation|keyboard It is not suitable, if you have different layouts for landscape and portraint orientations, when you need to... handle the configuration changes by overriding onSaveInsatnceState method of your Activity, save a state there and then use it in onCreate method. See this article for further explanation.

Pastebin. Com/ZdceXVzG I made the changes here. I keep getting a NullPointerException.

What am I doing wrong. – varunthacker Mar 21 at 10:30 What line causing NPE? What is globals in your code?

Why do you making a putAll call? Also, savedInstanceState is not always filled in (actually, on first activity start it it null), check it for null before doing a getString on it. – Olegas Mar 21 at 10:59.

You should save your button state. When screen orientation changes, onCreate is called and all your app variables are re-intitialized. Read more here developer.android.com/reference/android/....

I have a button which is basically used for start/stop. So initially the text of the button is set to start. I attached a OnClickListener to it.

So whenever it gets clicked I change its text. So if it was start it become stop and vice-versa. The problem comes when I change my phone view from portrait to landscape or vice-versa the button text gets reset.

So for example I clicked the start button---it changed to stop. Now if I tilt my phone to change the view the button text gets set to start again. Am I using the button in a wrong way?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions