【发布时间】:2018-03-01 05:10:52
【问题描述】:
我有一个主要活动,其中包括SwipeRefreshLayout。该活动包含fragments。
我想在特定片段中禁用SwipeRefreshLayout,因为SwipeRefreshLayout 的滑动手势会干扰片段上ExpandableListView 的滚动手势。
为此,我尝试了以下方法,但没有成功:
关于我拥有的片段:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.listfragment, container, false);
//......
expListView = (ExpandableListView) v.findViewById(R.id.expandableList);
final MainActivity mainAct = (MainActivity) getActivity();
//.......
expListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
Log.d("test","Disabled");
//SwipeRefreshLayout is called swipeRefreshLayout on MainActivity
mainAct.swipeRefreshLayout.setEnabled(false);
}
});
运行后,我可以看到日志消息,所以 swipeRefreshLayout 应该设置为 false,但是 SwipeRefreshLayout 的下拉手势正在工作
【问题讨论】:
-
同时发布您的活动代码
标签: android android-studio android-fragments expandablelistview swiperefreshlayout