Objective
Gallery's item uses a imageview+textview, and selector is set, and the item's state does not change when the SetSelection setting is used, which is present in the 2.2/2.3 system, The high version, like 4.0, does not exist.
Body
The first step is to solve the problem of ImageView state
Set for ImageView:android:focusableintouchmode= "true"
Note that the same property setting TextView is not available.
Second, manually control the text according to the status of different sets of different colors
2.1 Notify Gallery of adapter data updates in onconfigurationchanged notifydatasetchanged
2.2 Notify Gallery of adapter data updates in the onitemselected of gallery notifydatasetchanged
2.3 Modifying the text color according to the currently selected index in the GetView of gallery adapter
if (position = = Mgallery.getselecteditemposition ()) {
title.settextcolor (color_nav_selected);
} else
Title.settextcolor (Color_nav_normal);
where color_nav_selected and color_nav_normal are the selected and unselected colors respectively.
End
Note that the problem does not exist when manually sliding gallery, and that it exists by SetSelection changes Gallery The selected item, and does not exist in the high version.
That is the error analysis of Android (2.2/2.3 version) Gallery, hoping to help develop Android friends.