android - Weird textview.setText() inside adapter result -
in app i'm passing adapter (which extends arrayadapter>) such list: list<map<string, string>>
. single record list looks like: {received=true, text=some sort of text}
here's getview method:
@override public view getview(int position, view convertview, viewgroup parent) { map<string, string> singlerecord = new hashmap<string, string>(); singlerecord = records.get(position); view rowview = convertview; if (rowview == null) { layoutinflater layoutinflater = context.getlayoutinflater(); rowview = layoutinflater.inflate(record_layout, null); } //to test method do: string to_put = singlerecord.get(key_text); log.e("adapter", to_put); //// textview singletext = (textview) rowview.findviewbyid(r.id.singleid); singletext.settext(singlerecord.get(key_text)); //viewholder.singletext.settext(tekst); return super.getview(position, convertview, parent); }
as can see want textview settext map contains key: "key_text"; test if method works fine put in log , looks right, when i'm setting text of textview same text put in logcat (text map) i'm not getting value key : "key_text", i'm getting looks like: {received=true, text=some sort of text}
it's 1 record converted string. has idea why happening ?
please use below code:
@override public view getview(int position, view convertview, viewgroup parent) { map<string, string> singlerecord = new hashmap<string, string>(); view vi = convertview; singlerecord = records.get(position); vi = mlayoutinflater.inflate(r.layout.record_layout, null); textview tv1 = (textview) vi .findviewbyid(r.id.singleid); tv1.settext(singlerecord.get(key_text)); return vi; }
Comments
Post a Comment