据我所知,getView的目的是在每次"要求"适配器时"提供"ListView(或其他接口)的特定视图。我按位置得到了对象:
myItem = (myItem) getItem(position);
然后我检查了转换视图是否不为空,并初始化了一个默认布局:
itemLayout = (RelativeLayout) convertView;
if (itemLayout == null) {
LayoutInflater inflater = (LayoutInflater)mContext.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
itemLayout= (RelativeLayout) inflater.inflate (R.layout.my_item,null);
}
现在我想在我的项目/对象与其布局之间建立联系 - 或者换句话说:用该项目的值填充此布局的视图。
我该怎么做?还是我对整个概念的理解完全错误?
请检查Android ListView的ViewHolder模式或使用RecyclerView。