2

I'm trying to add Pull To Refresh feature to the Activity which already is using Merge Adapter made by Mark Myrphy aka @commonsware.

Here is our code:

                     //get container PTR listview
                    PullToRefreshListView ptrLvContainer = (PullToRefreshListView) findViewById(R.id.lv_merge_fragment);                        


                    //create adapter for bottom list view
                    lvAdapter = new ListViewAdapter(this, R.layout.adapter_row, alResults);

                    mMergeAdapter = new MergeAdapter();

                    //Create 2 rows of custom views, that will be set above the lvAdapter
                    LinearLayout llRow1 = new LinearLayout(this);
                    //here we add picture to llRow1
                    LinearLayout llRow2 = new LinearLayout(this);
                    //here we add 2 pictures to llRow2

                    //Add everything to mergeAdapter
                    mergeAdapter.addView(llRow1);
                    mergeAdapter.addView(llRow2);
                    mergeAdapter.addAdapter(lvAdapter);

                    //set mergeAdapter to Pull To Refresh ListView
                    ptrLvContainer.setAdapter(mergeAdapter);

And here is lv_merge_fragment.xml.

<?xml version="1.0" encoding="utf-8"?>
<com.handmark.pulltorefresh.library.PullToRefreshListView 
    xmlns:ptr="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    ptr:ptrMode="pullDownFromTop"
    ptr:ptrDrawable="@drawable/cell_home_top" 
    android:id="@+id/lv__merge_fragment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:cacheColorHint="#00000000"
    android:scrollbars="none"
    android:fadingEdge="none"
    android:divider="@android:color/transparent"

    android:listSelector="@android:color/transparent" >

</com.handmark.pulltorefresh.library.PullToRefreshListView>

I'm trying to get working together https://github.com/chrisbanes/Android-PullToRefresh and https://github.com/commonsguy/cwac-merge .

Unfortunately, there's a problem. MergeAdapter treats whole PullToRefresh listview as something to display from bottom to top, which makes the header (which is used as a PTR indicator), being visible all the time (not only after drag). There's no way I can make it to work, and rewriting one of the libs is a hard-way to get across this issue. Did anyone succesfully used CommonsWare MergeAdapter with Pull to Refresh libs in android? Screenshot attached for better understanding of what I'm trying to achieve. Basically the PTR action should reload all the view.

and here is what I want it to look/work like: enter image description here

Thanks in advance for the help.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Patrick
  • 472
  • 3
  • 16
  • If you have not done so already, try using the pull-to-refresh library with just one of your own adapters directly, rather than by way of `MergeAdapter`. If your problem persists, then the issue is not with `MergeAdapter`. Personally, I have not used the pull-to-refresh stuff, let alone with `MergeAdapter`. – CommonsWare Oct 26 '12 at 15:42
  • using normal adapter doesn't give the feature of putting few views inside one bigger adapter like mergeAdapter does, thus the quiestion. – Patrick Oct 26 '12 at 16:03
  • @Patrick, have you put it to work? Also can you provide the source code from 'lvAdapter'? – Marckaraujo Jan 15 '13 at 20:00
  • We resigned from PTR in views with MergeAdapter unfrtunately. If you want I can give you code from the Adapters used in ListView but there is nothing special at all. – Patrick Jan 16 '13 at 14:28

0 Answers0