java - How to get the value of a textview in a listview? -
i need value of textview in position of listview. how it?
myjava code:
protected void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); textview txttechcharacteristic = (textview) findviewbyid(r.id.techcharacteristic); textview txttechcharacteristicname = (textview) findviewbyid(r.id.techcharacteristicname); }
here textview ->.
layout listview:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <relativelayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <include layout="@layout/simple_back_action_bar" /> </relativelayout> <listview android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textsize="16sp"/> </linearlayout>
layout rows:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <textview android:id="@+id/techcharacteristic" android:textsize="20sp" android:textstyle="bold" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <textview android:id="@+id/techcharacteristicname" android:textsize="15sp" android:layout_width="wrap_content" android:layout_height="fill_parent"/> </linearlayout>
the code fill listview done within asynchronous method.here is:
public class populatetechcharacteristiclist extends asynctask<integer, string, integer> { progressdialog progress; context context; public populatetechcharacteristiclist(context context) { this.context = context; } protected void onpreexecute() { progress = progressdialog.show(techcharacteristiclist.this, getresources().getstring(r.string.wait), getresources() .getstring(r.string.loadingoperations)); } protected integer doinbackground(integer... paramss) { arraylist<techcharacteristic> arraytechchar = new arraylist<techcharacteristic>(); techcharacteristicwsqueries techcharwsqueries = new techcharacteristicwsqueries(); try { arraytechchar = techcharwsqueries .selecttechcharacteristicbyasset(asset); (techcharacteristic straux : arraytechchar) { hashmap<string, string> temp = new hashmap<string, string>(); temp.put("cod", straux.gettechcharacteristic() + " - " + straux.gettechcharacteristicname()); temp.put("value", "valor: " + straux.gettechcharacteristicvalue()); list.add(temp); } } catch (queryexception e) { e.printstacktrace(); return 0; } return 1; } protected void onpostexecute(integer result) { if (result == 1) { simpleadapter adapter = new simpleadapter( techcharacteristiclist.this, list, r.layout.techcharacteristic_rows, new string[] { "cod", "value" }, new int[] { r.id.techcharacteristic, r.id.techcharacteristicname }); setlistadapter(adapter); progress.dismiss(); } } }
onclick passes parent view "v"
just use
textview txttechcharacteristic = (textview) v.findviewbyid(r.id.techcharacteristic); string txt = txttechcharacteristic.gettext();
Comments
Post a Comment