码迷,mamicode.com
首页 > 其他好文 > 详细

ViewHolder 优化

时间:2016-06-12 20:20:42      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

 1   @Override
 2         public View getView(int position, View convertView, ViewGroup parent) {
 3             View view;
 4             Holder holder;
 5 
 6             if (convertView == null) {
 7                 view = View.inflate(MainActivity.this, R.layout.item, null);
 8                 holder = new Holder();
 9                 holder.img = (ImageView) view.findViewById(R.id.img);
10                 holder.button1 = (Button) view.findViewById(R.id.button1);
11                 holder.button2 = (Button) view.findViewById(R.id.button2);
12                 view.setTag(holder);
13             } else {
14                 view = convertView;
15                 holder = (Holder) view.getTag();
16             }
17 
18             return view;
19         }

 

ViewHolder 优化

标签:

原文地址:http://www.cnblogs.com/3674-it/p/5578597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!