Android 如何使用合并适配器向视图中添加“拉动到重新缩放”功能?
我正在尝试将Pull to Refresh功能添加到活动中,该活动已经在使用MarkMyrphy aka@commonware制作的合并适配器 这是我们的代码:Android 如何使用合并适配器向视图中添加“拉动到重新缩放”功能?,android,commonsware-cwac,Android,Commonsware Cwac,我正在尝试将Pull to Refresh功能添加到活动中,该活动已经在使用MarkMyrphy aka@commonware制作的合并适配器 这是我们的代码: //get container PTR listview PullToRefreshListView ptrLvContainer = (PullToRefreshListView) findViewById(R.id.lv_merge_fragment)
//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);
这里是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>
我正试着一起工作,一起学习
不幸的是,有一个问题。MergeAdapter将整个PullToRefresh listview视为从下到上显示的内容,这使得标题(用作PTR指示器)始终可见(而不仅仅是在拖动之后)。我没有办法让它工作,重写一个LIB是解决这个问题的一个困难的方法。有没有人成功地使用Commonware MergeAdapter和Pull来刷新android中的libs?附加屏幕截图,以便更好地了解我试图实现的目标。基本上,PTR操作应该重新加载所有视图
以下是我希望它的外观/工作方式:
提前感谢您的帮助。如果您还没有这样做,请尝试直接使用您自己的适配器之一使用pull-to-refresh库,而不是通过
MergeAdapter
。如果问题仍然存在,则问题不在于MergeAdapter
。就我个人而言,我还没有使用pull来刷新内容,更不用说使用MergeAdapter
。使用普通适配器没有像MergeAdapter那样在一个更大的适配器中放置几个视图的功能,因此没有任何问题。@Patrick,你已经使用它了吗?您还可以提供来自“lvAdapter”的源代码吗?我们在视图中以MergeAdapter的方式退出了PTR。如果需要,我可以从ListView中使用的适配器中为您提供代码,但没有任何特殊之处。