我在ListView
中有价值,但我无法选择任何值
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long i)
{
try{
String phone = adapter.tvPhone.getText().toString();
}
catch(Exception e) {
System.out.println("error 1:: " + e );
Log.i(" error1 :: "+e,null);
}
}
});"
答案 0 :(得分:0)
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long i)
{
try{
String phone = list.getItemAtPosition(position).toString();
Toast.makeText(getBaseContext(), phone, 1000).show();
}
catch(Exception e) {
System.out.println("error 1:: " + e );
Log.i(" error1 :: "+e,null);
}
}
});"
答案 1 :(得分:0)
如果你只有文本视图作为列表项,你可以这样做:
public void onItemClick(AdapterView<?> parent, View view, int position, long i)
{
try{
String phone = ((TextView)view).getText().toString();
}
catch(Exception e) {
System.out.println("error 1:: " + e );
Log.i(" error1 :: "+e,null);
}
}