android - Updating hashMap value on specific position -


i tried out lot ways update hashmap value on specific position not able do. have custom array list in stored hash map array list specific position array list. , in list view adapter creating dynamic linear layout on basis of count of hashmap array list, in linear layout have edit text also.

now on click of edit text of each item of linear layout. have update hash map value particular position , particular value.

my adapter code this:-

for (j = 0; j < arry_tickt_info.get(position).getarray_ticket_data().size(); j++) {  // create linearlayout linearlayout ll = new linearlayout(context); ll.setorientation(linearlayout.horizontal); linearlayout.layoutparams qntityparams = new linearlayout.layoutparams(0,60, 1f);  // create quantitiy edittext final edittext edqntity = new edittext(context); final arraylist<hashmap<string, string>> hashmaps = arry_tickt_info.get(j).getarray_ticket_data(); edqntity.settext(arry_tickt_info.get(position).getarray_ticket_data().get(j).get("quantity"));  edqntity.setonfocuschangelistener(new view.onfocuschangelistener() { @override public void onfocuschange(view v, boolean hasfocus) {     if (!hasfocus) {         final int position = v.getid();          (map.entry<string, string> e1 : hashmaps.get(integer.parseint(txthiddenid.gettext().tostring())).entryset()) {             string s = e1.getvalue();             string s1 = e1.getkey();              if (e1.getkey().equalsignorecase("quantity")) {                  string roundedoff = edqntity.gettext().tostring();                 e1.setvalue(string.valueof(roundedoff));                 log.e("updatedvalue::::", "updatedvalue::::" + roundedoff);             }         }     } } });  edqntity.setgravity(gravity.center_horizontal); edqntity.setems(2); edqntity.setheight(60); edqntity.setbackgroundresource(r.drawable.edittext_grey_outline); edqntity.settextcolor(color.parsecolor("#555555")); edqntity.setlayoutparams(qntityparams);  ll.addview(edqntity); } 

not sure trying do, update hashmap value can use same put function using set value previously. when use put create row key if not there, if key present update value key.

when doing first time:-

map.put("key","value1"); 

second time when want update:-

map.put ("key","value2"); //remember need have exact same key used while inserting entry. 

for arraylist have set(index, value); i.e.

arraylist<string> alstr = new arraylist<string>();  alstr.add ("abc"); 

for updating find index of "abc" , then

alstr.add (0, "abc"); //used 0 have 1 item. 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -