问题描述
我使用的是SwipeRefreshLayout和EnhancedListView他们喜欢Gmail应用内广告结合起来。当我开始刷卡水平,我仍然可以刷卡垂直。在这种情况下,从EnhancedListView动画卡,不复位或刷卡,直到结束,如果我没有完成垂直(SwipeRefreshLayout)刷卡。
我可以看到,首先拉来刷新,然后swipeToDismiss不起作用。只有先刷卡,然后刷新。所以我想它是关于beeing父元素。
可能的解决方案我想过:
检查水平滚动和swipeL.setEnabled(假)禁用SwipeRefreshLayout;完成后swipeL.setEnabled(真);但我找不到在哪里禁用和启用它。
我的布局:
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>< RelativeLayout的
机器人:ID =@ + ID /页脚
机器人:layout_width =match_parent
机器人:layout_height =50dp
机器人:layout_alignParentBottom =真
机器人:背景=#0A756E
机器人:比重=中心> <的LinearLayout
机器人:ID =@ + ID / ll_archiv
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@绘制/绿盒子> <的TextView
机器人:ID =@ + ID / tv_archiv
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingBottom会=10dp
机器人:paddingTop =10dp
机器人:文字=@字符串/档案馆
机器人:textAppearance =机器人:ATTR / textAppearanceMedium
机器人:文字颜色=#FFF/>
< / LinearLayout中>
< / RelativeLayout的>< android.support.v4.widget.SwipeRefreshLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / swipe_container
机器人:layout_width =match_parent
机器人:layout_height =match_parent> < de.android.voucheroo.utils.EnhancedListView
机器人:ID =@机器人:ID /列表
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_above =@ ID /页脚
机器人:layout_alignParentTop =真
机器人:descendantFocusability =blocksDescendants>
< /de.android.voucheroo.utils.EnhancedListView>
< /android.support.v4.widget.SwipeRefreshLayout>
我的code:
swipeL =(SwipeRefreshLayout)getActivity()。findViewById(
R.id.swipe_container);
ll_archiv =(的LinearLayout)getActivity()findViewById(R.id.ll_archiv)。
。tv_archiv =(TextView中)getActivity()findViewById(R.id.tv_archiv);
ELV =(EnhancedListView)getActivity()findViewById(android.R.id.list)。
elv.setDismissCallback(新OnDismissCallback(){ @覆盖
公共撤销onDismiss(EnhancedListView的ListView,
最终诠释位置){
尝试{
最终对象担保= voucher.get(位置);
voucher.remove(位置);
adapter.notifyDataSetChanged();
返回新EnhancedListView.Undoable(){ @覆盖
公共无效撤消(){
voucher.add(位置,担保);
adapter.notifyDataSetChanged();
} //返回一个字符串为您的项目
@覆盖
公共字符串的getTitle(){
返回富;
} //从持久性存储完全删除项目
@覆盖
公共无效丢弃(){
[...];
}
};
}赶上(例外五){
Log.w(ELV_EXCEPTION,e.getMessage());
e.getStackTrace();
返回null;
}
}
});
swipeL.setOnRefreshListener(新OnRefreshListener(){ @覆盖
公共无效onRefresh(){
[...]
swipeL.setRefreshing(假);
}
}); //处理程序
elv.enableSwipeToDismiss();
elv.setSwipingLayout(R.id.ll_parent);
elv.setUndoStyle(UndoStyle.MULTILEVEL_POPUP);
Nowsaday我知道我自己的问题的答案。这不是我的code的一个问题,它与SwipeRefreshView一个问题。
有同样的问题,我发现这里类似的问题:
I am using a SwipeRefreshLayout and an EnhancedListView to combine them like GMAIL-App. When I start to swipe horizontal I am still be able to swipe vertical. In this case the animation from EnhancedListView stuck and do not reset or swipe till the end if I do not complete the vertical (SwipeRefreshLayout) swipe.
I can see, that first pull to refresh and then swipeToDismiss does not work. Only first swipe and then refresh. So i guess it is about beeing a parent element.
Possible Solution i thought about:Check for horizontal scrolling and disable SwipeRefreshLayout with swipeL.setEnabled(false); When finished swipeL.setEnabled(true); But I can not find where to disable and enable it.
My Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="#0A756E"
android:gravity="center" >
<LinearLayout
android:id="@+id/ll_archiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/greenbox" >
<TextView
android:id="@+id/tv_archiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="@string/archiv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>
<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" >
<de.android.voucheroo.utils.EnhancedListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/footer"
android:layout_alignParentTop="true"
android:descendantFocusability="blocksDescendants" >
</de.android.voucheroo.utils.EnhancedListView>
</android.support.v4.widget.SwipeRefreshLayout>
My Code:
swipeL = (SwipeRefreshLayout) getActivity().findViewById(
R.id.swipe_container);
ll_archiv = (LinearLayout) getActivity().findViewById(R.id.ll_archiv);
tv_archiv = (TextView) getActivity().findViewById(R.id.tv_archiv);
elv = (EnhancedListView) getActivity().findViewById(android.R.id.list);
elv.setDismissCallback(new OnDismissCallback() {
@Override
public Undoable onDismiss(EnhancedListView listView,
final int position) {
try {
final Object vouch = voucher.get(position);
voucher.remove(position);
adapter.notifyDataSetChanged();
return new EnhancedListView.Undoable() {
@Override
public void undo() {
voucher.add(position, vouch);
adapter.notifyDataSetChanged();
}
// Return a string for your item
@Override
public String getTitle() {
return "foo";
}
// Delete item completely from your persistent storage
@Override
public void discard() {
[...];
}
};
} catch (Exception e) {
Log.w("ELV_EXCEPTION", e.getMessage());
e.getStackTrace();
return null;
}
}
});
swipeL.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
[...]
swipeL.setRefreshing(false);
}
});
// Handler
elv.enableSwipeToDismiss();
elv.setSwipingLayout(R.id.ll_parent);
elv.setUndoStyle(UndoStyle.MULTILEVEL_POPUP);
Nowsaday I know the answer of my own question. It is not a problem with my code, it is a problem with SwipeRefreshView.
There is a similar question with the same Problem I found here: SO-Answer
这篇关于EnhancedListView SwipeRefreshLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!