简单的方式有三种:

 @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;
        }

 

相关文章:

  • 2022-01-29
  • 2021-10-10
  • 2021-08-30
  • 2021-06-21
  • 2022-12-23
  • 2021-08-27
  • 2021-05-03
  • 2022-01-14
猜你喜欢
  • 2021-07-03
  • 2021-07-14
  • 2022-12-23
  • 2021-07-10
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案