在android中的适配器中是否有可能显示成员和值成员?这意味着listView的value成员将被隐藏
答案 0 :(得分:0)
您需要做的是构建一个包含对象列表的自定义Adapter
。
对象
public class MyObject {
private int id;
private String name;
}
适配器
public class MyObjectListAdapter extends ArrayAdapter<MyObject> {
private final Context context;
public MyObjectListAdapter(Context context, List<MyObject> objects) {
super(context, R.layout.listview_myobjects, objects);
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.listview_myobject_item, parent, false);
TextView textViewName = (TextView) rowView.findViewById(R.id.textViewObjectName);
MyObject current = getItem(position);
textViewName.setText(current.getName());
return rowView;
}
}
Lars Vogel详细介绍了ListView
,详情请看:
http://www.vogella.com/articles/AndroidListView/article.html