android - How to set color for position '0' of ExpandableListview -


i have 4 activity classes, need implement 4 different colors 4 activities, have expandablelistadapter like:

public class expandablelistadapter extends baseexpandablelistadapter {  private context _context; private list<string> _listdataheader; // header titles // child data in format of header title, child title private hashmap<string, list<string>> _listdatachild; string colors;  public expandablelistadapter(context context, list<string> listdataheader,         hashmap<string, list<string>> listchilddata,string color) {     this._context = context;     this._listdataheader = listdataheader;     this._listdatachild = listchilddata;     this.colors=color; }  @override public object getchild(int groupposition, int childposititon) {     return this._listdatachild.get(this._listdataheader.get(groupposition))             .get(childposititon); }  @override public long getchildid(int groupposition, int childposition) {     return childposition; }  @override public view getchildview(int groupposition, final int childposition,         boolean islastchild, view convertview, viewgroup parent) {      final string childtext = (string) getchild(groupposition, childposition);      if (convertview == null) {         layoutinflater infalinflater = (layoutinflater) this._context                 .getsystemservice(context.layout_inflater_service);         convertview = infalinflater.inflate(r.layout.list_item, null);     }      checkedtextview txtlistchild = (checkedtextview) convertview             .findviewbyid(r.id.lbllistitem);     txtlistchild.settypeface(typefaceconstant.getgibsonregular(_context));     txtlistchild.settext(childtext);      return convertview; }  @override public int getchildrencount(int groupposition) {     if(groupposition==2){         return this._listdatachild.get(this._listdataheader.get(groupposition))                 .size();     }else         return 0;  }  @override public object getgroup(int groupposition) {     return this._listdataheader.get(groupposition); }  @override public int getgroupcount() {     return this._listdataheader.size(); }  @override public long getgroupid(int groupposition) {     return groupposition; }  @override public view getgroupview(int groupposition, boolean isexpanded,         view convertview, viewgroup parent) {     string headertitle = (string) getgroup(groupposition);     if (convertview == null) {         layoutinflater infalinflater = (layoutinflater) this._context                 .getsystemservice(context.layout_inflater_service);         convertview = infalinflater.inflate(r.layout.list_group, null);     }      checkedtextview lbllistheader = (checkedtextview) convertview             .findviewbyid(r.id.lbllistheader);     lbllistheader.settypeface(typefaceconstant.getgibsonregular(_context));      lbllistheader.settext(headertitle);      return convertview; }  @override public boolean hasstableids() {     return false; }  @override public boolean ischildselectable(int groupposition, int childposition) {     return true; } 

and activity class like:

 public class officescreenactivity extends fragmentactivity implements onclicklistener {  linearlayout office,roaster,food_service,hospitality;   expandablelistadapter listadapter; expandablelistview explistview; list<string> listdataheader; textview lbllistheader,office_text;  imageview play,logo,office_image; linearlayout ln; context context; bundle bundle; arraylist<content> al;  hashmap<string, list<string>> listdatachild;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_office_screen);       play=(imageview) findviewbyid(r.id.play_button);     logo=(imageview) findviewbyid(r.id.logo_button);      roaster=(linearlayout) findviewbyid(r.id.roaster_lay);     food_service=(linearlayout) findviewbyid(r.id.food_lay);     hospitality=(linearlayout) findviewbyid(r.id.hosp_lay);      office_image=(imageview) findviewbyid(r.id.office_image);     office_image.setimageresource(r.drawable.office_color);      office_text=(textview) findviewbyid(r.id.office_text);     office_text.settextcolor(color.parsecolor("#57b7b2"));        roaster.setonclicklistener(this);     food_service.setonclicklistener(this);     hospitality.setonclicklistener(this);     play.setonclicklistener(this);     logo.setonclicklistener(this);      fragmentmanager fm;     introductionfragment fragment = new introductionfragment();     bundle bundle = new bundle();     string str="    office coffiee \n have talking.";      string str1="sola";     string str2=" bev office coffee system solutions";     final string colors="#57b7b2";     //bundle.putstring("office",str);     bundle.putstring("sola", str1);     bundle.putstring("bev", str2);     bundle.putstring("office",str);     bundle.putstring("color", colors);     fragment.setarguments(bundle);          fm=getsupportfragmentmanager();         fm.begintransaction().replace(r.id.frame1, fragment, "newfragmenttag").commit();       // listview             explistview = (expandablelistview) findviewbyid(r.id.lvexp);               // preparing list data             preparelistdata();              listadapter = new expandablelistadapter(this, listdataheader, listdatachild,colors);              // setting list adapter             explistview.setadapter(listadapter);              // listview group click listener              //explistview.setbackgroundcolor(color.parsecolor("#57b7b2"));             explistview.setongroupclicklistener(new ongroupclicklistener() {                 checkedtextview lastclickedview;                   @override                 public boolean ongroupclick(expandablelistview parent, view v,                         int groupposition, long id) {                       if(groupposition==0){                           fragmentmanager fm;                                 introductionfragment fragment = new introductionfragment();                                 bundle bundle = new bundle();                                 string str="    office coffiee \n have talking.";                                 string str1="sola";                                 string colors="#57b7b2";                                 string str2=" bev office coffee system solutions";                                 bundle.putstring("office",str);                                 bundle.putstring("sola", str1);                                 bundle.putstring("bev", str2);                                 bundle.putstring("color", colors);                                 fragment.setarguments(bundle);                                      fm=getsupportfragmentmanager();                                     fm.begintransaction().replace(r.id.frame1, fragment, "newfragmenttag").commit();                        }                     else if(groupposition==1){                           fragmentmanager fm;                                 keypointsfragment fragment = new keypointsfragment();                                  bundle bundle = new bundle();                             string token="office";                                 bundle.putstring("office", token);                                 fragment.setarguments(bundle);                                      fm=getsupportfragmentmanager();                                     fm.begintransaction().replace(r.id.frame1, fragment, "newfragmenttag").commit();                       }                     else if(groupposition==3){                           fragmentmanager fm;                                 presentationsfragment fragment = new presentationsfragment();                                 bundle bundle = new bundle();                                 string str="presentations";                                 //string str1="sola";                                 string colors="#57b7b2";                                 //string str2=" bev office coffee system solutions";                                 bundle.putstring("present_title",str);                                 bundle.putstring("cate_id", "1");                                 //bundle.putstring("sola", str1);                                 //bundle.putstring("bev", str2);                                 bundle.putstring("color", colors);                                 fragment.setarguments(bundle);                                      fm=getsupportfragmentmanager();                                     fm.begintransaction().replace(r.id.frame1, fragment, "newfragmenttag").commit();                        }                       if(null!=lastclickedview){                              lastclickedview.setbackgroundcolor(color.parsecolor("#232323"));                       }                       checkedtextview txt3=(checkedtextview) v.findviewbyid(r.id.lbllistheader);                       if(!(groupposition==2)){                            txt3.setbackgroundcolor(color.parsecolor("#57b7b2"));                            //txt3.settypeface(typefaceconstant.getgibsonbold(getapplicationcontext()));                         lastclickedview=txt3;                       }                       if(groupposition==2){                      lbllistheader = (textview) v                             .findviewbyid(r.id.lbllistheader);                      lbllistheader.settextcolor(color.parsecolor("#b0afaf"));                     }                       return false;                 }             });              // listview group expanded listener             explistview.setongroupexpandlistener(new ongroupexpandlistener() {                  @override                 public void ongroupexpand(int groupposition) {                     toast.maketext(getapplicationcontext(),                             listdataheader.get(groupposition) + " expanded",                             toast.length_short).show();                 }             });              // listview group collasped listener             explistview.setongroupcollapselistener(new ongroupcollapselistener() {                  @override                 public void ongroupcollapse(int groupposition) {                     if(groupposition==2){                     lbllistheader.settextcolor(color.parsecolor("#ffffff"));                     }                     toast.maketext(getapplicationcontext(),                             listdataheader.get(groupposition) + " collapsed",                             toast.length_short).show();                  }             });              // listview on child click listener             explistview.setonchildclicklistener(new onchildclicklistener() {                 checkedtextview lastclickedview;                 @override                 public boolean onchildclick(expandablelistview parent, view v,                         int groupposition, int childposition, long id) {                     // todo auto-generated method stub                     if(childposition==0){                             intent minhome1112 = new intent(officescreenactivity.this,brewersactivity.class);                           minhome1112.putextra("cate_id", "1");                             officescreenactivity.this.startactivity(minhome1112);                      }                     else if(childposition==1){                            intent minhome1112 = new intent(officescreenactivity.this,capsulesactivity.class);                           minhome1112.putextra("cate_id", "1");                           minhome1112.putextra("avtivity", "office");                             officescreenactivity.this.startactivity(minhome1112);                      }                     if(null!=lastclickedview){                              lastclickedview.setbackgroundcolor(color.parsecolor("#232323"));                       }                       checkedtextview txt1=(checkedtextview) v.findviewbyid(r.id.lbllistitem);                            txt1.setbackgroundcolor(color.parsecolor("#57b7b2"));                         lastclickedview=txt1;                        toast.maketext(                             getapplicationcontext(),                             listdataheader.get(groupposition)                                     + " : "                                     + listdatachild.get(                                             listdataheader.get(groupposition)).get(                                             childposition), toast.length_short)                             .show();                     return false;                 }                 });         } 

this 1 of activity classes, have 4 activity classes these, please me.

you passing colors string in expandablelistadapter's constructor never used it. if want set first group item's color need set getgroupview() method of expandablelistadapter : this:

if(groupposition==0){ lbllistheader.settextcolor(<color passing in constructor>); } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -