Tips for small student experience

Source: Internet
Author: User

Tips for small student experience

If your UI is a GridView ListView control, you need to use the adapter to add data.

So sometimes the data in the List changes <> If the content changes, it is necessary to update the data.

Update the adapter data

Ada. notifyDataSetInvalidated ();

Ada. notifyDataSetChanged ();

The previous post by a senior is a good metaphor

We can use the granary to explain the difference between the two.

NotifyDataSetChanged: if there is less or more grain in the granary, a notification is sent.

NotifyDataSetInvalidated: the granary is changed. For example, the grain obtained from Warehouse A is now changed to the granary B.

In different cases, you can call unused functions for updates.

---------------------- Gorgeous split line ------------------------------------

However, in my tests, I found that I was In the first situation, but only changed the data content and did not change the address. No New data source was available, call yydatasetchanged () to solve the problem.

However, when I need to delete one of the items, subtract NUM by one, and call notifyDataSetChanged (), the first Item or the first few items are lost!

Click an Item and the icon returns to the normal number.

 

Finally, multiple tests showed that at the beginning, my items were 10 items. If you add or delete one Item to control the number of items to be greater than or equal to 10 items and call yydatasetchanged (), no problem will occur.

When you add or delete two items and the number of items becomes 9, the number of items is less than the number of items you set adapter () at the beginning.

I only found this rule, but I don't know the principle. If a great God knows it, please leave your answer. We also hope to help the children's shoes on the cards.

 

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.