Android (2.2/2.3 system) gallery resolves the default and down-screen toggle check State problem _android

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.