开发者

Android orientation change

I am downloading an image from a server a开发者_JAVA技巧nd adding it as left drawable to different buttons. The problem is when I rotate the emulator, all the left drawables of buttons are reloaded.

I also tried adding android:configChanges="orientation" to manifest file but that doesn't help.

Is there anything I am doing wrong or is there a particular procedure for it?


Whenever the screen is rotated, the Activity is restarted and all your drawables need to be loaded again.

To stop it from reloading, add this to your manifest:

android:screenOrientation="portrait"

This will keep your activity in portrait mode at all times.

If you do wish to be able to change the orientation, you can use these methods

onSaveInstanceState
onRestoreInstanceState

to keep your drawables in memory and reload them when the activity runs onResume

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜