android - Implementing the headers as FloatingGroupExpandableListView -
i have custom listview in listfragment
3 types of headers(1st.green background, 2nd.black background, 3rd.gray background), can see in video.
i want customize greenish header, i.e on click of greenish header views(items) between next greenish header must minimized, & 1 time again clicking in greenish header views minimized should exapanded.
the same functionality floatinggroupexpandablelistview uses dummy items, in case views have customized.
i have no thought how can modify code accomplish task.
public class contentsfragment extends listfragment implements ontouchlistener { final context context = getactivity(); private mycustomadapter madapter; activity temp = getactivity(); textview tv1,tv3; string []s = new string[500]; arraylist<gs> q = new arraylist<gs>(); listview lv; int count=0; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); dbadapter db = dbadapter.getdbadapter(getactivity()); if (!db.checkdatabase()) db.createdatabase(getactivity()); db.opendatabase(); q = db.getdata(); madapter = new mycustomadapter(getactivity()); madapter.addgreenseparatoritem(new contentwrapper("part i", null, null, null, null));//group madapter.addseparatoritem(new contentwrapper(q.get(0).geta_name(),null,null,null,null));//child madapter.additem(new contentwrapper(q.get(0).getas_name(), q.get(0).getdesc_art(),q.get(0).getextra(),q.get(0).getpart(),q.get(0).getitalic()));//child (int = 1; <= 14; i++) { if(i==5) madapter.addgreenseparatoritem(new contentwrapper("part ii", null, null, null, null)); if(i==12) madapter.addgreenseparatoritem(new contentwrapper("part iii", null, null, null, null)); if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null));//child madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } (int = 15; < 36; i++) { if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null)); madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } madapter.additem(new contentwrapper(q.get(460).getas_name(), q.get(460).getdesc_art(),q.get(460).getextra(),q.get(460).getpart(),q.get(460).getitalic())); (int i=36; < 158; i++) { if(i==41) madapter.addgreenseparatoritem(new contentwrapper("part iv", null, null, null, null));//group if(i==60) madapter.addgreenseparatoritem(new contentwrapper("part iva", null, null, null, null));//group if(i==61) madapter.addgreenseparatoritem(new contentwrapper("part v", null, null, null, null)); if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null)); madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } madapter.additem(new contentwrapper(q.get(461).getas_name(), q.get(461).getdesc_art(),q.get(461).getextra(),q.get(461).getpart(),q.get(461).getitalic())); (int i=158; < 210; i++) { if(i==163) madapter.addgreenseparatoritem(new contentwrapper("part vi", null, null, null, null)); if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null)); madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } madapter.additem(new contentwrapper(q.get(462).getas_name(), q.get(462).getdesc_art(),q.get(462).getextra(),q.get(462).getpart(),q.get(462).getitalic())); (int i=210; < 218; i++) { if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null)); madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } madapter.additem(new contentwrapper(q.get(463).getas_name(), q.get(463).getdesc_art(),q.get(463).getextra(),q.get(463).getpart(),q.get(463).getitalic())); (int i=218; < 244; i++) { if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null)); madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } madapter.additem(new contentwrapper(q.get(464).getas_name(), q.get(464).getdesc_art(),q.get(464).getextra(),q.get(464).getpart(),q.get(464).getitalic())); (int i=244; < 459; i++) { if(i==248) madapter.addgreenseparatoritem(new contentwrapper("part vii", null, null, null, null)); if(i==249) madapter.addgreenseparatoritem(new contentwrapper("part viii", null, null, null, null)); if(i==257) madapter.addgreenseparatoritem(new contentwrapper("part ix", null, null, null, null)); if(i==273) madapter.addgreenseparatoritem(new contentwrapper("part ixa", null, null, null, null)); if(i==291) madapter.addgreenseparatoritem(new contentwrapper("part x", null, null, null, null)); if(i==293) madapter.addgreenseparatoritem(new contentwrapper("part xi", null, null, null, null)); if(i==314) madapter.addgreenseparatoritem(new contentwrapper("part xii", null, null, null, null)); if(i==353) madapter.addgreenseparatoritem(new contentwrapper("part xiii", null, null, null, null)); if(i==360) madapter.addgreenseparatoritem(new contentwrapper("part xiv", null, null, null, null)); if(i==377) madapter.addgreenseparatoritem(new contentwrapper("part xiva", null, null, null, null)); if(i==379) madapter.addgreenseparatoritem(new contentwrapper("part xv", null, null, null, null)); if(i==386) madapter.addgreenseparatoritem(new contentwrapper("part xvi", null, null, null, null)); if(i==400) madapter.addgreenseparatoritem(new contentwrapper("part xvii", null, null, null, null)); if(i==421) madapter.addgreenseparatoritem(new contentwrapper("part xix", null, null, null, null)); if(i==431) madapter.addgreenseparatoritem(new contentwrapper("part xx", null, null, null, null)); if(i==432) madapter.addgreenseparatoritem(new contentwrapper("part xxi", null, null, null, null)); if(i==455) madapter.addgreenseparatoritem(new contentwrapper("part xxii", null, null, null, null)); if (!(q.get(i).geta_name().trim().equals(q.get(i-1).geta_name().trim()))) { madapter.addseparatoritem(new contentwrapper(q.get(i).geta_name(), null,null,null,null)); } if(!(q.get(i).getextra()==null)) madapter.addgrayseparatoritem(new contentwrapper(q.get(i).getextra(),null,null,null,null)); madapter.additem(new contentwrapper(q.get(i).getas_name(), q.get(i).getdesc_art(),q.get(i).getextra(),q.get(i).getpart(),q.get(i).getitalic())); } setlistadapter(madapter); } //adapter class private class mycustomadapter extends baseadapter { private static final int type_item = 0; private static final int type_separator = 1; private static final int type_gray_separator = 2; private static final int type_green_separator = 3; private static final int type_max_count = type_green_separator + 1; private treeset<integer> mseparatorsset = new treeset<integer>(); private treeset<integer> mgrayseparatorsset = new treeset<integer>(); private treeset<integer> mgreenseparatorsset = new treeset<integer>(); private arraylist<contentwrapper> mdata = new arraylist<contentwrapper>(); private layoutinflater minflater; public mycustomadapter(context context) { minflater = layoutinflater.from(context); } public void additem(contentwrapper value) { mdata.add(value); notifydatasetchanged(); } public void addseparatoritem(contentwrapper value) { mdata.add(value); // save separator position mseparatorsset.add(mdata.size() - 1); notifydatasetchanged(); } public void addgrayseparatoritem(contentwrapper value) { mdata.add(value); // save separator position mgrayseparatorsset.add(mdata.size() - 1); notifydatasetchanged(); } public void addgreenseparatoritem(contentwrapper value) { mdata.add(value); // save separator position mgreenseparatorsset.add(mdata.size() - 1); notifydatasetchanged(); } public contentwrapper getitem(int position) { homecoming mdata.get(position); } @override public int getitemviewtype(int position) { int viewtype = type_item; if(mseparatorsset.contains(position)) viewtype = type_separator; else if(mgrayseparatorsset.contains(position)) viewtype = type_gray_separator; else if(mgreenseparatorsset.contains(position)) viewtype = type_green_separator; homecoming viewtype; // homecoming mseparatorsset.contains(position) ? type_separator : type_item; } @override public int getviewtypecount() { homecoming type_max_count; } public int getcount() { homecoming mdata.size(); } public long getitemid(int position) { log.v("getitemid position", ""+position); homecoming position; } public view getview(final int position, view convertview, viewgroup parent) { viewholder holder = null; int type = getitemviewtype(position); if (convertview == null) { holder = new viewholder(); switch (type) { case type_item: convertview = minflater.inflate(r.layout.white, null); holder.textview = (textview)convertview.findviewbyid(r.id.text); break; case type_separator: convertview = minflater.inflate(r.layout.black, null); holder.textview = (textview)convertview.findviewbyid(r.id.textseparator); break; case 2: convertview = minflater.inflate(r.layout.gray, null); holder.textview = (textview)convertview.findviewbyid(r.id.textviewgray); break; case 3: convertview = minflater.inflate(r.layout.green, null); holder.textview = (textview)convertview.findviewbyid(r.id.textseparatorgreen); break; } convertview.settag(holder); } else { holder = (viewholder)convertview.gettag(); } holder.textview.settext(mdata.get(position).getitem()); getlistview().setfastscrollenabled(true); if (type == type_item) { holder.textview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { final dialog dialog = new dialog(getactivity()); dialog.requestwindowfeature(window.feature_no_title); dialog.setcontentview(r.layout.description); textview desc = (textview) dialog.findviewbyid(r.id.textview3); textview part = (textview) dialog.findviewbyid(r.id.textview1); textview italic = (textview) dialog.findviewbyid(r.id.textview2); textview title = (textview) dialog.findviewbyid(r.id.textview4); italic.settypeface(null, typeface.italic); title.settext(mdata.get(position).getitem()); desc.settext(mdata.get(position).getitemdescription()); part.settext(mdata.get(position).getpart()); italic.settext(mdata.get(position).getitalic()); dialog.show(); dialog.setcancelable(true); dialog.setcanceledontouchoutside(true); } }); }else if(type == 1) { holder.textview.setonclicklistener(null); } else if(type == 2) { holder.textview.setonclicklistener(null); } homecoming convertview; } } public static class viewholder { public textview textview; public textview header; int previoustop = 0; } public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub homecoming false; } }
thank you, please help . . . . .
i did not reviewed code, here thought how accomplish it:
obviously cannot minimize all, list view nowadays part of views while actual amount of views minimize may much larger.
also after minimized views need minimized, cannot nowadays them empty views(height = 0), because list empty.
so solve sec problem, recommend manipulate info exclude views.
the first problem much harder solve, , need compromise how. can minimize visible views, entire list view might smaller or hall created within it. , after minimization finish update data, , reset of views supposed visible there in boom. work if have 1 or 2 views minimize, how ever not perfect idea.
the other solution forget list view, , have views in memory, think way of achieving it.
in general hard task.
android android-listview
No comments:
Post a Comment