展会信息港展会大全

Adapter性能优化,在getView方法中利用缓存,如果发现View还没有被...
来源:互联网   发布日期:2016-01-14 11:33:23   浏览:2528次  

导读:public class Adapter extends BaseAdapter { private Context context; public TodoAdapter(Context context) { this.context = context; } @Override public int getCount() { return todos.size(); } @Override public Object getItem(int position) { re...

public class Adapter extends BaseAdapter {

private Context context;

public TodoAdapter(Context context) {

this.context = context;

}

@Override

public int getCount() {

return todos.size();

}

@Override

public Object getItem(int position) {

return todos.get(0);

}

@Override

public long getItemId(int position) {

return position;

}

@Override

public View getView(int position, View convertView, ViewGroup parent) {

View view = convertView;

if (view == null) {

LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

view = layoutInflater.inflate(R.layout.item_layout, parent, false);

}

// Set View Details

return view;

}

}

赞助本站

人工智能实验室

相关热词: android开发 android教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港