【发布时间】:2015-12-10 11:28:28
【问题描述】:
所以我有课:
class student{
public int id;
public String name;
}
然后我有一个学生类型的适配器数组,并且该适配器被传递给列表视图。我想知道如何让列表视图只显示学生的姓名。 代码:
ListView list=(ListView)findViewById(R.id.list_day_wise_expense);
ArrayAdapter<Student> adapter = new ArrayAdapter<Student>( this,R.layout.increase_size_text, kids);
list.setAdapter(adapter);
其中kids 是Student 对象的数组,而list 是我的列表视图。 我希望列表显示他们的名字。
【问题讨论】:
-
使用应返回您的 Student 类的 adapter.getItem(position) 。然后你可以对其执行 student.name 或 getName() 。
-
查看tutorial。
标签: android listview android-listview