栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

无条件布局,从视图适配器膨胀:应该使用视图持有人模式

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

无条件布局,从视图适配器膨胀:应该使用视图持有人模式

试试这个

static class ViewHolder {    private TextView friendsname;    private ImageView thumb_image;    private CheckBox cb;}public View getView(final int position, View convertView, ViewGroup parent) {    ViewHolder mViewHolder = null;    HashMap<String, String> song = null;    if (convertView == null) {        song = new HashMap <String, String>();        mViewHolder = new ViewHolder();        LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);        convertView = vi.inflate(R.layout.activity_friend_list_row, parent, false);        mViewHolder.friendsname = (TextView) convertView.findViewById(R.id.friendsName); // title        mViewHolder.thumb_image = (ImageView) convertView.findViewById(R.id.list_image); // thumb image        mViewHolder.cb = (CheckBox) convertView.findViewById(R.id.checkBox);        convertView.setTag(mViewHolder);        mViewHolder.cb.setTag(data.get(position));        mViewHolder.cb.setonCheckedChangeListener(new onCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean ischecked) {     InviteFriends.isChecked[position] = buttonView.isChecked(); }        });    } else {        mViewHolder = (ViewHolder) convertView.getTag();    }    song = mViewHolder.cb.getTag();    mViewHolder.friendsname.setText(song.get(InviteFriends.KEY_DISPLAY_NAME));    mViewHolder.imageLoader.DisplayImage(song.get(InviteFriends.KEY_IMAGEPROFILE_URL), thumb_image);    mViewHolder.cb.setChecked(InviteFriends.isChecked[position]);    return convertView;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/438492.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号