Android loader-restart the loader

Source: Internet
Author: User

When using the initloader () method, if the loader with the specified ID exists, use the existing loader. Otherwise, a new loader is created. However, sometimes you want to discard the old data and restart the loader.

You can use restartloader () to discard old data. For example, the implementation of searchview. onquerytextlistener restarts the loader when the user queries the changes. The loader needs to be restarted to use the corrected search filter for new queries, such:

Public Boolean onquerytextchanged (string newtext ){
// Called when the action bar search text has changed. Update
// The search filter, and restart the loader to do a new Query
// With this filter.
Mcurfilter =! Textutils. isempty (newtext )? Newtext: NULL;
Getloadermanager (). restartloader (0, null, this );
Return true;

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: 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.