Android gets the ImageView picture level

Source: Internet
Author: User

Android gets the ImageView picture level issue

To implement features such as, click Share to show the selected and unchecked status, and then send is based on the status to achieve the specific sharing function.

There are 5 subkeys in the GridView, each child element has two pictures, the level setting of a, a, 0, 1, click the picture to make the picture ab switch, the previous question is to be able to know the current picture of the rank . But here only the method of setting the level, set the picture level Setimagelevel (1);

You can see the picture level of the current child element at debug, as follows:

Cannot get current level, can only change ideas: Define an array, corresponding to the state of each child element

Final int[] Listseld = new int[] {0, 0, 0, 0, 0};//0 unchecked, 1 selected

Then in the GridView click event to get the current child element, according to the current state, change the level, as follows:

//Add a Click eventPlatformlayout.setonitemclicklistener (NewOnitemclicklistener () {@Override Public voidOnitemclick (adapterview<?> arg0, view view,intArg2,LongArg3) {                //Arg1 is the view of the current item, through which you can get the individual components in the item. //ARG2 is the ID of the current item.                This ID can be defined by your own notation in the adapter. //Arg3 is the relative position of the current item in the ListView! ImageView Ss_indicator =(ImageView) View.findviewbyid (r.id.ss_indicator); //if (ss_indicator.isselected ()) {//ss_indicator.setselected (false);                if(LISTSELD[ARG2] = = 0) {                    //if unchecked, set to selectedLISTSELD[ARG2] = 1; Ss_indicator.setimagelevel (1); } Else{LISTSELD[ARG2]= 0; Ss_indicator.setimagelevel (0); }                //} else {//ss_indicator.setselected (TRUE); // }                intindex = arg2 + 1;//The ID is starting from 0, so it takes +1Toast.maketext (Getapplicationcontext (), "You pressed the option:" + index, 0). Show (); }        });

The benefit is that you can finally know the selected collection. Another way is to isselected the method, such as the comment section, but ultimately not as good as the first scenario.

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.