刚接触Android(Java),我想从“自定义ListView”中获取所选用户的值,以下是我尝试检索数据的示例代码
ContactsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView> parent, View view,int position, long id) {
// String str= ContactsListView.getSelectedItem();
//String selectedFromList = (ContactsListView.getItemAtPosition(position).toString());
String val = parent.getAdapter().getItem(position).toString();
Log.i("Item", "Selected: " + val);
}
});
但这就是越来越
02-04 18:16:31.773 10255-10255/com.app.com.sms I/Item: Selected:
com.app.com.smsapp.ThreeStrings@42829718 02-04 18:16:33.323
10255-10255/com.app.com.sms I/Item: Selected:
com.app.com.smsapp.ThreeStrings@428297c0 02-04 18:16:34.463
10255-10255/com.app.com.sms I/Item: Selected:
com.app.com.smsapp.ThreeStrings@42829718
这是我的适配器
06001
public class ThreeStrings {
private String left;
private String right;
private String centre;
private String bottom;
public ThreeStrings(String left, String right, String centre, String bottom) {
this.left = left;
this.right = right;
this.centre = centre;
this.bottom = bottom;
}
public String getLeft() {
return left;
}
public String getCentre() {
return centre;
}
public String getRight() {
return right;
}
public String getBottom() {return bottom;}
}
在listView中将定位中心作为选定值.如何获得所选商品的价值/中心?