java - ActionBarPullToRefresh doesn't work when list is empty -


i using chris banes actionbar-pulltorefresh on listfragment.

everything works fine except when listview empty. when listview empty (and empty text visible), pull refresh functionality doesn't work altough did set getlistview().getemptyview() in thesechildrenarepullable().

i tried allchildrenarepullable() didn't work.

the code listfragment:

@override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      listadapter = new listsadapter(getactivity(), items);     setlistadapter(listadapter);      cursor cursor = listprovider.getinstance().selectall();     arraylist<basemodel> cursoritems = listprovider.getinstance().rowstoarraylist(cursor);     for(basemodel cursoritem : cursoritems) {         items.add((listmodel) cursoritem);     } }  public void onactivitycreated(bundle savedstate) {     super.onactivitycreated(savedstate);     registerforcontextmenu(getlistview()); }  @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view layout = inflater.inflate(r.layout.adapter_lists, container, false);     return layout; }  @override public void onviewcreated(view view, bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);     getlistview().setonitemlongclicklistener(this);      mpulltorefreshlayout = new pulltorefreshlayout(getactivity());      actionbarpulltorefresh.from(getactivity())             .insertlayoutinto((viewgroup) view)             .thesechildrenarepullable(getlistview(), getlistview().getemptyview())             .listener(this)             .setup(mpulltorefreshlayout); } 

the code adapter_lists.xml:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent">      <listview android:id="@id/android:list"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_weight="1"         android:drawselectorontop="false"/>      <textview android:id="@id/android:empty"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:gravity="center"         android:text="@string/message_my_lists_empty"/>  </linearlayout> 

so fixed using swiperefreshlayout native.

to working need view:

<android.support.v4.widget.swiperefreshlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/swipe_container"     android:layout_width="match_parent"     android:layout_height="match_parent">      <scrollview         android:layout_width="match_parent"         android:layout_height="match_parent">          <textview             android:text="@string/hello_world"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_margintop="16dp"             android:gravity="center"/>      </scrollview>  </android.support.v4.widget.swiperefreshlayout> 

and code in onviewcreated function:

swipelayout = (swiperefreshlayout) findviewbyid(r.id.swipe_container); swipelayout.setonrefreshlistener(this); swipelayout.setcolorscheme(     android.r.color.holo_blue_bright,      android.r.color.holo_green_light,      android.r.color.holo_orange_light,      android.r.color.holo_red_light); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -