android - Prevent expandable listview from showing its child during a long swipe -


i have implemented 2 features on expandable listview.

  1. the child view should shown when user clicks on group view (which happens default)
  2. have implemented left right long swipe listener in if user long swipe , taken new activity

both these actions working fine. when long swipe across screen, listview opens , shows child element (see 1 above) before being taken new activity.

relevant portion of 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 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 avoid this.

i figured out way fix this. overriding ongroupclick() function in following way 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;             }         }); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -