private List<SomeModel> modelLists = null; private class MyListSomeModelAdapter extends BaseAdapter{ @Override public int getCount() { return modelLists.size(); } @Override public Object getItem(int position) { return modelLists.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if(convertView == null){ convertView = View.inflate(context, R.layout.some_item_view, null); viewHolder = new ViewHolder(); viewHolder.tvNum1 = (TextView) convertView.findViewById(R.id.tv_num1); viewHolder.tvNum2 = (TextView) convertView.findViewById(R.id.tv_num2); convertView.setTag(viewHolder); }else{ viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.tvNum1.setText(modelLists.get(position).getNum1()); viewHolder.tvNum2.setText(modelLists.get(position).getNum2()); return convertView; } static class ViewHolder{ TextView tvNum1; TextView tvNum2; }
时间: 2024-10-16 16:45:09