android - Expandable list issue: setting group textview maxLine and expanding the list same time -


if there multiple lines of text in group textview of expandable list

what want -: when first list loaded, 1 line appears in every group , when user click on group lines in group should visible + group should expanded @ same time.

i have tried implement that, when click on group view in list, got expanded lines of text in group not visible when click on same group again, lines visible.

this what, have tried:

in group getview method have set maximum lines of textview 1.

  public view getgroupview(int i, boolean b, view view, viewgroup viewgroup) {             textview textview = new textview(correctqafragment.this.getactivity());             textview.settext(getgroup(i).tostring());              textview.setmaxlines(1);    //set maximum lines of textview 1.                 return textview;         } 

elv- refrence expandable list.

 elv.setongroupclicklistener(new ongroupclicklistener() {              public boolean ongroupclick(expandablelistview parent, view v,                     int groupposition, long id) {                  textview tv = (textview)v;                 tv.setmaxlines(integer.max_value); //set max lines max value                  parent.expandgroup(groupposition); //expand group                  return true;               }         }); 

yea, tried , got answer. problem every time getgroupview method called when expand group in expandable list view , i'am setting maxline 1, that's why on first time click group text lines not visible.

so here solution worked me.

 public view getgroupview(int i, boolean b, view view, viewgroup viewgroup) {         textview textview = new textview(correctqafragment.this.getactivity());         textview.settext(getgroup(i).tostring());        if (b) {            textview.setmaxlines(integer.max_value);               }else{             textview.setmaxlines(1);   //set maximum lines of textview 1.               }              return textview;     } 

ongroupclicklistener-:

 elv.setongroupclicklistener(new ongroupclicklistener() {          public boolean ongroupclick(expandablelistview parent, view v,                 int groupposition, long id) {              parent.expandgroup(groupposition); //expand group              return true;           }     }); 

explanation:- check group expanded or not in getgroupview method , set maxline textview accordingly as:

         if (b) {            textview.setmaxlines(integer.max_value);               }else{             textview.setmaxlines(1);   //set maximum lines of textview 1.               }  

where b boolean returned isgroupexpand. b = true --> group expanded vice versa.

and remove lines listener setting textview max lines.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -