Getting The Values Of Listview Selected Item
I have this ListView adapter: public class UpicksAdapter extends BaseAdapter { Context context; List upick_list; public UpicksAdapter(List l
Solution 1:
Change this code to setters.
upick.Subject_Name = jsonObject.getString("id_servicio");upick.Subject_Full_Form = jsonObject.getString("cliente_servicio");
eg:
upick.setSubjectname(jsonObject.getString("id_servicio"));
Then inside onclick you can take values using getters
String item = upicks.get(position).getSubjectname();
parent.getItemAtPosition(position)
will return an Object (the model used in your adapter).To get some field from your Object don't call Object.toString(); it will return the object reference not the value that you're looking for. Use Object.yourField; instead.
Solution 2:
The ArrayList.get() method is used to get the element of a specified position within the list.
String str_ITEM= upicks.get(position).yourGETMETHOD();
Solution 3:
in your callback listener you have adapter object just use that like below.
UpicksListView.setOnItemClickListener(newAdapterView.OnItemClickListener() {
@OverridepublicvoidonItemClick(AdapterView<?> parent, View view, int position,
long id) {
Stringitem= parent.getSelectedItem().toString();
Log.d("VALOR","VALOR "+item);
}
});
Post a Comment for "Getting The Values Of Listview Selected Item"