Coder Social home page Coder Social logo

Comments (6)

erikwt avatar erikwt commented on September 28, 2024

You should do this on the UI thread. You can use runOnUiThread(..) or View.Post(..) or similar.

from pulltorefresh-listview.

schilakamarri avatar schilakamarri commented on September 28, 2024

Hi Erik, I could not get it to work at all. I have a async task that I start as follows in my OnCreate Method in my activity:

new RefreshTask().execute.

It has OnPreExecute(), DoInBackground() and OnPostExecute() methods.

Where do you think I should include listView.setRefreshing()? Can you give an example?

Thank you!

from pulltorefresh-listview.

erikwt avatar erikwt commented on September 28, 2024

I suppose you should do that call in onPostExecute(..). Can you post the code that doesn't work for you? Maybe in a gist?

from pulltorefresh-listview.

schilakamarri avatar schilakamarri commented on September 28, 2024

It does not work when I place listView.setRefreshing() in onPostExecute() method.

I run a asynctask from onCreate() method as:

public void onCreate(Bundle savedInstanceState) {
pull_listView = (PullToRefreshListView) app.findViewById(R.id.pull_to_refresh_listview);
pull_listView.setShowLastUpdatedText(true);
pull_listView.setLastUpdatedDateFormat(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"));
pull_listView.setTextPullToRefresh("Pull to Refresh");
pull_listView.setTextReleaseToRefresh("Release to Refresh");
pull_listView.setTextRefreshing("Refreshing..");
MyAsycTask.execute();
...
...
}

And then:

private class MyAyncTask extends AsyncTask<Void, Void, String[]> {

     protected void onPreExecute() {

     }
     protected String[] doInBackground(Void... params) {
           //some HTTP calls made
      }

     protected void onPostExecute(String[] result) {
       // a  pull_listView is populated 
        pull_listView.onRefreshComplete();
     }

}

from pulltorefresh-listview.

erikwt avatar erikwt commented on September 28, 2024

Ah, the setRefreshing() should be called in onPreExecute(), then onRefreshComplete() in onPostExecute(). Does that work for you? Also, be sure to check the sample project for the exact function calls.

from pulltorefresh-listview.

miao1007 avatar miao1007 commented on September 28, 2024

Thanks ! It works fine on my fragment 👍

from pulltorefresh-listview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.