我有一個主要活動,其中包括一個SwipeRefreshLayout
。該活動包含fragments
。從片段中禁用MainActivity SwipeRefreshLayout
我想從特定片段中禁用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
應設置到假,但是對於SwipeRefreshLayout下拉手勢工作
安置自己的活動代碼以及 –