Favorites, how do I like buttons by the current status (Favorites/Cancel collection) by clicking Set to cancel collection (favorites)

Source: Internet
Author: User

See here, I want to introduce me to this collection button (pentagram), repeatedly clicked to cater to the user experience. How to meet the repeated click Set state?

The request is this: I click on the Favorites button (assuming: The original collection button is not a collection (dark color)), when I clicked on the collection, the button is lit to orange. When I click on it again, of course, I want to know the current status of the Favorites button (dark color?). is still lit). It then sets its relative state to it based on the state at that time.

Have a lot of friends, use the flag bit, set a status bit on it. For example, let 1 (Favorites) 0 (not collection), after each click through the button has been set the last time the flag bit to set the state again after the click, or more complex way. I think it is really complicated, so think and think, finally smart me, think of a good way!

This is based on my project!

When requesting data in the background, such as the data from the latest script above. So what I get is a list<dramabookbean>, and then in Dramabookbean there are these attributes: the URL of the picture, the name of the script, the brief introduction, the type, the price, the state of the Favorites button. Note: This property has the status of the Favorites button! Then it is good to do, do not have any sign bit settings, are too annoying kinky. We should make full use of the status value of the collection button requested from the background. To do this: at first, enter (in the adapter) by the state value of the button to determine when the ListView is displayed when the TA should be how the state, and through the status of the state value to determine the status of the setting. Then, when we click on it, it is assumed that the dark color is not a collection of the original state. Click Time, First judge (the status value is not collected), by the background request from the status of the value to determine later set its status as a collection. Also, use the adapter under Dramabookbean to synchronize the collection status of the button under its corresponding item. Of course, the entire operation process is not finished, this is only in the adapter, and when it calls TA's activity, through the interface callback listener click events, in the activity to commit data to the server synchronization data, due to the network of accidental problems, Success or failure to synchronize update two objects at this time (the Dramabookbean object in the adapter's button collection status values and activity in the Dramabookbean object in your home collection status values) the value of the collection state;

So, that is to say: every time I operate, in this related Dramabookbean (adapter, acitivity) to update the state value of the favorite button, so that when the click Operation again can be obtained and according to the state that is currently displayed, To set the status that should be displayed after the click Operation!

Favorites, how do I like buttons by the current status (Favorites/Cancel collection) by clicking Set to cancel collection (favorites)

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.