开发者

Gallery's onItemSelected is called after orientan change BUT with no reference to position the first element

Whenever my activity with a gallery is FIRST created the onItemSelected method is automatically called passing the 0 parameter for position and a reference to the 0th element(textview). That is fine. But when I change orientation and the activity is recreated, although the onItemSelected method is called again automatically the parameters are not what I'd expect. The selected position is still passed for the position but null is passed for the view parameter, in other words I can't reference the selected element.

I do开发者_C百科n't understand this behavior at all. Why is there no reference for the selected view?

(I need to change the text color of selected element based on the Bundle I get in onCreate but I don't have a reference to it.)


It's better not to recreate your Activity again, it's really resource-consuming and a waste. Just setting to keep it

These references might help:
http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges
http://thinkandroid.wordpress.com/2009/12/27/handling-configuration-changes-or-not/

If it's ok, please post your code, I'd like to analyze your case at object referencing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜