listview下如何获取view的方法
当你想在View中获取数据时这个
LayoutInflater.from(mContext).inflate(R.layout.list_item,parent,false)
有用。它会将View中设置的图片、字符串等所有数据保存起来。然后你就可以分拣了。
public View getView(int position, View convertView, ViewGroup parent) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item,parent,false);
ImageView img_icon = (ImageView) convertView.findViewById(R.id.imgtou);
TextView txt_aName = (TextView) convertView.findViewById(R.id.name);
TextView txt_aSpeak = (TextView) convertView.findViewById(R.id.says);
img_icon.setBackgroundResource(mData.get(position).getaIcon());
txt_aName.setText(mData.get(position).getaName());
txt_aSpeak.setText(mData.get(position).getaSpeak());
return convertView;
}