I have this below code access the ListView item value into string and display it in alert?
ListView shot = getListView();
shot.setOnItemClickListener(this);
Maybe you can try this
String data = (String)shot.getItemAtPosition(arg2);
AlertDialog.Builder adb = new AlertDialog.Builder(arg1.getContext());
adb.setMessage(data).show();
To get the value of your model
adaptor.getItem(position).getCardName();
This gives you the exact value of the item clicked. Check the log
ListView shot = getListView();
shot.setOnItemClickListener(this);
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
String val =(String) parent.getItemAtPosition(position);
System.out.println("Value is "+val);
}
maybe this example will help you
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();
}
});
https://developer.android.com/reference/android/widget/ListView.html