KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
in my Android app I have created a ListView component called myList, and filled it with objects of my own custom type: class MyClass{ private String displayName; private String theValue; ... //here constructor, getters, setters and toString() are implemented } I used the ArrayAdapter to bound the ArrayList theObjects with myList: ArrayAdapter<MyClass> adapter= new ArrayAdapter<MyClass>(this, R.layout.lay_item, theObjects); myList.setAdapter(adapter); This works fine, the list is populated and etc., but when I'm trying to access the selected item, i receive a Null object. I've done this using myList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View v, int position, long id) { MyClass selItem = (MyClass) myList.getSelectedItem(); // String value= selItem.getTheValue(); //getter method } What seems to be the problem? Thank you
Tags (comma-separated)
Save Edits
Cancel