Comments (6)
You should do this on the UI thread. You can use runOnUiThread(..) or View.Post(..) or similar.
from pulltorefresh-listview.
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.
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.
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.
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.
Thanks ! It works fine on my fragment 👍
from pulltorefresh-listview.
Related Issues (20)
- Flicker when setAdapter HOT 1
- Place listView below another view HOT 1
- animation "stutters" if listview has padding HOT 3
- when the listview is refreshing I can not click the item to turn to another activity
- Divider appears before the first item HOT 3
- ClassCastException preventing PullToRefreshListView from inflating
- eu.erikw.PullToRefreshListView failed to instantiate
- Customize the distance from when "Release to refresh" is showed
- PullToRefresh_ListView in ViewPager HOT 2
- "Pull to refresh" banner disappears if I scroll to the bottom of the list HOT 1
- bouncing animation problem
- PullToRefresh banner gets locked when scrolling quickly HOT 1
- ListView not Visible entire list items (or) some items are not completely displayed HOT 2
- Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.RelativeLayout HOT 1
- java.lang.IllegalStateException HOT 4
- setOnItemClickListener has the wrong position. HOT 3
- ptr_header.xml should include layout_width/layout_height or it will cause exception
- How to use with listfragment
- PTRListView below other layouts
- Pull to left or right and show icon from left or right
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pulltorefresh-listview.