ListView适配器获取布局文件作为View的三种方式

第一种方法:

public View getView(int position, View convertView, ViewGroup parent)
{
View view = null; if (convertView != null)
{
view = convertView;
} else
{
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.item_view, null);
}
...
}

第二种方法:

public View getView(int position, View convertView, ViewGroup parent)
{
View view = null; if (convertView != null)
{
view = convertView;
} else
{
view = LayoutInflater.from(context).inflate(R.layout.item_view,null);
}
...
}

第三种方法:

    public View getView(int position, View convertView, ViewGroup parent)
{
View view = null; if (convertView != null)
{
view = convertView;
} else
{
view = View.inflate(context, R.layout.item_view, null);
}
...
}
上一篇:vue-cli搭建项目模拟后台接口数据,webpack-dev-conf.js文件配置


下一篇:外网不能访问阿里云服务器的apache服务