如何快速獲取ListView的打氣筒對象

簡單的方式有三種:ide

 @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;
        }
相關文章
相關標籤/搜索