Preface
Gallery's Item uses an ImageView + TextView and sets selector for it. The Item status will not change when setSelection is used and the screen is switched horizontally and vertically, this currently exists in systems 2.2 and 2.3. a later version, such as 4.0, does not exist.
StatementWelcome to repost, but please keep the original source of the article :) blog Park: http://www.cnblogs.com
Farmer's uncle: http://over140.cnblogs.com
Body
1. Step 1: Solve the ImageView status problem
Set for ImageView
Android: focusableInTouchMode = "true"
Note that TextView settings for the same attribute are not used.
Step 2: manually control the text to set different colors based on different States
2.1 notify Gallery of Adapter data update notifyDataSetChanged in onConfigurationChanged
2.2 notify Gallery's Adapter data update notifyDataSetChanged in onItemSelected of Gallery
2.3 modify the text color based on the selected index in getView of the Gallery Adapter.
If (position = mGallery. getSelectedItemPosition ()){
Title. setTextColor (COLOR_NAV_SELECTED );
} Else
Title. setTextColor (COLOR_NAV_NORMAL );
COLOR_NAV_SELECTED and COLOR_NAV_NORMAL are the selected and unselected colors respectively.
End
Note: this problem does not exist when you manually slide the Gallery. It exists when you change the Gallery selected item through setSelection and does not exist in the later version.