如何快速获取ListView的打气筒对象
Posted dylansuns
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何快速获取ListView的打气筒对象相关的知识,希望对你有一定的参考价值。
简单的方式有三种:
@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的打气筒对象的主要内容,如果未能解决你的问题,请参考以下文章
如何将片段中的 ListView 对象的数据传递给 Activity?