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

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

时间:2018-11-22 00:04:07      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:group   text   ems   system   sys   div   int   class   ice   

简单的方式有三种:

 @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的打气筒对象

标签:group   text   ems   system   sys   div   int   class   ice   

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

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