i want fetch edit text data expandable list view,how can fetch position of edit text in activity because have find id of edit text on adapter?
here code
activity
public class addnewaddressactivity extends activity implements onclicklistener { expandablelistadapter listadapter; expandablelistview explistview; list<string> listdataheader; hashmap<string, list<string>> listdatachild; // private relativelayout _mainrl = null; private relativelayout _rlbacktocart = null; private linearlayout _llpay = null; private textview _tvcart = null; private textview _tvheader = null; private textview _tvpay = null; private textview _tvfromlisttxt = null; private textview _tvnewonetxt = null; private imageview _addnewaddressbtn = null; private textview _saveaddressbtn = null; //tint systembartintmanager tintmanager; private relativelayout _rlheader = null; //font typeface font; int _maintainaddress = 0; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.add_new_address_screen); _mainrl =(relativelayout) findviewbyid(r.id.mainrl); _rlbacktocart = (relativelayout) findviewbyid(r.id.back_to_cart_rl); _llpay = (linearlayout) findviewbyid(r.id.pay_ll); _tvcart = (textview) findviewbyid(r.id.carttxt); _tvheader = (textview) findviewbyid(r.id.add_new_address_headertv); _tvpay = (textview) findviewbyid(r.id.paytxt); _tvfromlisttxt = (textview) findviewbyid(r.id.fromlisttxt); _tvnewonetxt = (textview) findviewbyid(r.id.newonetxt); _rlheader = (relativelayout) findviewbyid(r.id.header_rl); _addnewaddressbtn = (imageview) findviewbyid(r.id.add_new_address); _saveaddressbtn = (textview) findviewbyid(r.id.saveaddressbtn); explistview = (expandablelistview) findviewbyid(r.id.exp_list); listdataheader = new arraylist<string>(); listdatachild = new hashmap<string, list<string>>(); // preparing list data // preparelistdata(); //font font = typeface.createfromasset(getassets(),"century_gothic.ttf"); _tvcart.settypeface(font); _tvheader.settypeface(font); _tvpay.settypeface(font); _tvfromlisttxt.settypeface(font); _tvnewonetxt.settypeface(font); //on click _rlbacktocart.setonclicklistener(this); _llpay.setonclicklistener(this); _addnewaddressbtn.setonclicklistener(this); _mainrl.setonclicklistener(this); _saveaddressbtn.setonclicklistener(this); // changestatus bar code if (build.version.sdk_int > build.version_codes.kitkat) { constant.changestatusbarcolor(addnewaddressactivity.this); }else { relativelayout.layoutparams params = (relativelayout.layoutparams)_rlheader.getlayoutparams(); params.setmargins(0,28,0,0); _rlheader.setlayoutparams(params); settranslucentstatus(true); tintmanager = new systembartintmanager(this); tintmanager.setstatusbartintenabled(true); tintmanager.setstatusbartintresource(r.color.grey); } } private void settranslucentstatus(boolean on) { // todo auto-generated method stub window win = getwindow(); windowmanager.layoutparams winparams = win.getattributes(); final int bits = windowmanager.layoutparams.flag_translucent_status; if (on) { winparams.flags |= bits; } else { winparams.flags &= ~bits; } win.setattributes(winparams); } @override public void onbackpressed() { // todo auto-generated method stub super.onbackpressed(); overridependingtransition(r.anim.left_to_right, r.anim.right_to_left); //for button } @override public void onclick(view v) { switch (v.getid()) { case r.id.back_to_cart_rl: finish(); overridependingtransition(r.anim.left_to_right, r.anim.right_to_left); //for button break; case r.id.pay_ll: intent _int = new intent(addnewaddressactivity.this, confirmorderactivity.class); startactivity(_int); overridependingtransition(r.anim.enter, r.anim.exit); break; case r.id.add_new_address: if(listdataheader.size()<5) { _maintainaddress = _maintainaddress + 1; system.out.println("value maintain"+_maintainaddress); listdataheader.add("address "+_maintainaddress); // adding child data list<string> address1 = new arraylist<string>(); address1.add(""); address1.add(""); address1.add(""); address1.add(""); address1.add(""); address1.add(""); address1.add(""); address1.add(""); address1.add(""); int = _maintainaddress - 1; listdatachild.put(listdataheader.get(i), address1); // header, child data listadapter = new expandablelistadapter(addnewaddressactivity.this, listdataheader, listdatachild); // setting list adapter explistview.setadapter(listadapter); listadapter.notifydatasetchanged(); } break; case r.id.mainrl: constant.hidekeyboard(addnewaddressactivity.this); break; case r.id.saveaddressbtn: for(int = 0;i<listdataheader.size();i++) { (int j = 0; j < listdatachild.size(); j++) { } } break; default: break; } }
on click of saveaddressbutton want fetch edit text value of adapter
here adapter class
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; typeface font; public static edittext txtlistchild = null; public expandablelistadapter(context context, list<string> listdataheader, hashmap<string, list<string>> listchilddata) { this._context = context; this._listdataheader = listdataheader; this._listdatachild = listchilddata; } @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.exp_list_item, null); } txtlistchild = (edittext) convertview .findviewbyid(r.id.expedt); imageview _expandcountry = (imageview) convertview.findviewbyid(r.id.exapandcountry); spinner _spncountry = (spinner) convertview.findviewbyid(r.id.country_spinner); arraylist<string> _countyarrlist = new arraylist<string>(); _countyarrlist.add("india"); _countyarrlist.add("usa"); _countyarrlist.add("uae"); _countyarrlist.add("south africa"); arrayadapter<string> _coloradap = new arrayadapter<string>(_context, r.layout.spinner_country, _countyarrlist); _coloradap.setdropdownviewresource(r.layout.spinner_country); _spncountry.setadapter(_coloradap); _spncountry.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(adapterview<?> parent, view view, int position, long id) { /*if (_transferto[position].equalsignorecase("select location")) { _transfertospinner.setselection(position); _location = _transfertospinner.getselecteditem().tostring(); } else { _location = _transfertospinner.getselecteditem().tostring(); //system.out.println("selected location" + _location); _transfertospinner.setselection(position); }*/ } @override public void onnothingselected(adapterview<?> parent) { // todo auto-generated method stub } }); txtlistchild.settext(childtext); if(childposition==0) { txtlistchild.sethint("name"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==1) { txtlistchild.sethint("last name"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==2) { txtlistchild.sethint("address line 1"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==3) { txtlistchild.sethint("address line 2"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==4) { txtlistchild.sethint("phone"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==5) { txtlistchild.sethint("city"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==6) { txtlistchild.sethint("state"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==7) { txtlistchild.sethint("zip code"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); txtlistchild.setvisibility(view.visible); _expandcountry.setvisibility(view.gone); _spncountry.setvisibility(view.gone); } else if(childposition==8) { txtlistchild.sethint("country"); txtlistchild.sethinttextcolor(_context.getresources().getcolor(r.color.grey)); _expandcountry.setvisibility(view.visible); _spncountry.setvisibility(view.visible); txtlistchild.setvisibility(view.gone); } return convertview; } @override public int getchildrencount(int groupposition) { system.out.println("group position"+groupposition); return this._listdatachild.get(this._listdataheader.get(groupposition)).size(); } @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.exp_list_group, null); } typeface.createfromasset(_context.getassets(),"century_gothic.ttf"); textview lbllistheader = (textview) convertview.findviewbyid(r.id.addresstxt); linearlayout _panellayout = (linearlayout) convertview.findviewbyid(r.id.exp_maingrp_rl); imageview _righticon = (imageview) convertview.findviewbyid(r.id.rightbtn); imageview _openclosebtn = (imageview) convertview.findviewbyid(r.id.openclosebtn); int panelbackid = isexpanded ? r.drawable.panel_active_tab: r.drawable.panel_inactive ; _panellayout.setbackgroundresource(panelbackid); int textresourceid = isexpanded ? _context.getresources().getcolor(r.color.white) : _context.getresources().getcolor(r.color.grey) ; lbllistheader.settextcolor(textresourceid); lbllistheader.settypeface(font); lbllistheader.settext(headertitle); int imageresourceid = isexpanded ? r.drawable.right_white : r.drawable.right_black ; _righticon.setimageresource(imageresourceid); int imageopencloseid = isexpanded ? r.drawable.arrow_bottom : r.drawable.forward_iv_black ; _openclosebtn.setimageresource(imageopencloseid); return convertview; } @override public boolean hasstableids() { return false; } @override public boolean ischildselectable(int groupposition, int childposition) { return true; } }
i make edit text static access in activity can not fetch position of edit text because using multiple edit text.
please me.
suggestions appreciated
thank
- you have store data application class access on save button.
you can create public method adapter return clicked edit text data.
private static arraylist<string> selectededittextdata; public arraylist<string> getclickededittextdata() { return selectededittextdata; }
add clicked edit text data arraylist on
getchildview
onclicklistner.- make arraylist application class store values of edit text views, generate getter , setter it.
- in activity after set adapter list.
- get values
getclickededittextdata()
activity , set global arraylist. - use getarraylist method on save button application class.
basically, can add entered data arraylist separately , getdata it.
Comments
Post a Comment