Comments (9)
Hi, I haven't had time to read up much on Fragments. What would be the benefits to use fragments here? Sorry if it's obvious but I guess it would get me started faster if I can get the big picture direct.
from android-pulltorefresh.
ListFragment
(like ListActivity
) is just a thin veil around a ListView
with some helper methods so providing your own pull refresh version is probably outside the scope of this library.
That's not so say that it wouldn't be useful for an individual making an app. To roll your own, copy the source of ListFragment
from the compatibility library and replace its ListView
instantiation with this library. It should be fairly easy.
from android-pulltorefresh.
Thank you Jake, will look into it and see if there's a point wrapping it, just don't want to end up wrapping it and maintaining something that's not really a part of this project.
However reading the docs for ListFragment
there's seems to be an example on how to provide your own layout. It might work to just provide a layout with the PullToRefreshListView
since it's compatible with ListView
.
from android-pulltorefresh.
That's true and a good solution for using native Fragments on 3.0+. If you are using the compatibility library a word of caution: make sure you are using the IDs defined in the ListFragment
class and not android.R.id.list
or you'll get some wonky errors.
from android-pulltorefresh.
Thanks for the heads up it seems like you have to use @id/android:list
when using a custom layout. Have you or someone else done a write up of the problems using this ID with ListFragment
?
from android-pulltorefresh.
Hey, I was able to use your library in a fragment using the method described in this post. Thanks for the great lib! http://stackoverflow.com/questions/8648040/how-to-implement-pull-to-refresh-on-a-listfragment
from android-pulltorefresh.
Thank you for the update. Would you mind setting up the needed fixes in a pull request and I would be happy to merge it.
from android-pulltorefresh.
Hi,
It's not that simple unfortunately.
ListFragment comes with methods to hide/show the list when busy and show a progress indicator while loading.
This mechanism requires a custom view hierarchy returned from the 'onCreateView' method. In fact it's a FrameLayout with views for the progress, empty text etc.
The idea is to override that onCreateView and replace the default ListView with a PullToRefresh ListView.
Here is the code that works now:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup viewGroup = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
View lvOld = viewGroup.findViewById(android.R.id.list);
final PullToRefreshListView listView = new PullToRefreshListView(getActivity());
listView.setId(android.R.id.list);
listView.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
listView.setDrawSelectorOnTop(false);
FrameLayout parent = (FrameLayout) lvOld.getParent();
parent.removeView(lvOld);
lvOld.setVisibility(View.GONE);
parent.addView(listView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return viewGroup;
}
@johannilsson You could ship with a sample PullToRefreshListFragment that inherits from ListFragment. People could change the import or switch to SherlockListFragment if they want.
from android-pulltorefresh.
Or maybe keep it simply as a Gist. :) Understand it's not in the scope of this project.
from android-pulltorefresh.
Related Issues (20)
- PullToRefreshListView的GridView,分页时,下一页如果只有一个数据不能马上显示,需要稍微往上拖动下,再往下拖动才可显示出数据,是怎么回事呢? HOT 2
- Tap to refresh always showing HOT 3
- How to set Typeface of text in list HOT 6
- Pull the bottom HOT 1
- Throwing an Exception in this Demo HOT 2
- mLastMotionY not correctly set HOT 2
- expandable list view HOT 1
- Listview on ItemClick gives wrong position HOT 8
- scroll problem HOT 1
- Lag when pulling, (lazy loading image).
- NullPointer when clicking on list items HOT 1
- Works only with linked list HOT 4
- Pull to refresh effect is not working HOT 1
- How to show pull-to-refresh automatically? HOT 3
- Sometimes getting tap to refresh HOT 2
- failed to disable Tap to refresh HOT 1
- Boundary instability issue
- Fast scrolling jump to first visible row
- Possible to add "Load More" button at footer view to loat more data?
- the activity will crashed when I pull to refresh crazily HOT 1
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 android-pulltorefresh.