I have an array of classes from a database being displayed in a listview. When a row is clicked on the listview I want all the data from that instance of the class to be displayed in textviews elsewhere on the page. The class I am using is a Player class which also includes a playerid.
I have tried something like this but it does not work, any help would be great thanks!
playerlistview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listView, View view,
int position, long id) {
Player selplayer = (Player) playerlistview.getAdapter().getItem(position);
String playername = selplayer.name;
String playerposition = selplayer.position;
String playerdob = selplayer.dob;
String playergoals = selplayer.goals;
String playerpoints = selplayer.points;
txtplayername.setText(playername);
txtplayerposition.setText(playerposition);
txtplayerdob.setText(playerdob);
txtplayergoals.setText(playergoals);
txtplayerpoints.setText(playerpoints);
}
});
AndroidRuntime(793): java.lang.ClassCastException: com.example.corkgaaapp.Squad$Player cannot be cast to android.database.Cursor
AndroidRuntime(793): at com.example.corkgaaapp.Squad$1.onItemClick(Squad.java:97)