首页 > 其他 > 详细

如何快速获取ListView的打气筒对象

时间:2018-11-21 23:24:49      阅读:215      评论:0      收藏:0      [点我收藏+]

简单的方式有三种:

 @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            if (convertView == null) {
                // 获取打气筒的三种方式
                // 方式一:
                // view = View.inflate(getApplicationContext(), R.layout.item, null);

                // 方式二:
                // view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.item, null);

                // 方式三:
                LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.item, null);
            } else {
                view = convertView;
            }

            return view;
        }

 

如何快速获取ListView的打气筒对象

原文:https://www.cnblogs.com/Dylansuns/p/9998171.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!