Reputation: 1119
I have implemented two features on my expandable listview.
Both these actions are working fine. But when I do a long swipe across the screen, the listview opens and shows the child element too (see 1 above) before being taken to a new activity.
Relevant portion of the code is:
ExpandableListView elvCat;
.
.
.
mAdapter = new SimpleExpandableListAdapter(
WordListFragment.this.getActivity(),
groupDataCat,
R.layout.word_list_item,
new String[] {WORD},
new int[] { R.id.tvWord },
childDataCat,
R.layout.meaning_list_item,
new String[] {MEANING},
new int[] { R.id.tvMeaning}
);
elvCat.setAdapter(mAdapter);
.
.
elvCat.setOnGroupClickListener(new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView arg0, View arg1, int arg2,
long arg3) {
if (swipeDetector.swipeDetected()) {
if (swipeDetector.getAction() == SwipeDetector.Action.LR) {
elvCat.collapseGroup(arg2);
Toast.makeText(getActivity(),
"Left to right", Toast.LENGTH_SHORT).show();
}
if (swipeDetector.getAction() == SwipeDetector.Action.RL) {
Intent detailIntent = new Intent(getActivity(), WordDetailActivity.class);
startActivity(detailIntent);
}
}
return false;
}
});
Please tell me how to avoid this.
Upvotes: 0
Views: 430
Reputation: 1119
I figured out the way to fix this. Overriding ongroupclick() function in the following way does the trick.
@Override
public boolean onGroupClick(ExpandableListView arg0, View arg1,
int arg2, long arg3) {
if (swipeDetector.swipeDetected()) {
if (swipeDetector.getAction() == SwipeDetector.Action.LR) {
return true;
}
if (swipeDetector.getAction() == SwipeDetector.Action.RL) {
return true;
}
} else {
return false;
}
return false;
}
});
Upvotes: 1