java代码:
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.topic_list, null); holder.title = (TextView) convertView.findViewById(R.id.title); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } } public class ViewHolder { public TextView getTitle() { if (title == null) { title = (TextView) baseView.findViewById(R.id.title); } return title; } }
java代码:
holder = new ViewHolder(); convertView = inflater.inflate(R.layout.topic_list, null); holder.title = (TextView) convertView.findViewById(R.id.title);
java代码:
public View HashMap<Integer, View> m = new HashMap<Integer, View>(); public View getView(int position, View view, ViewGroup parent) { View convertView = m.get(position); if (convertView != null) { return convertView; } else { convertView = inflater.inflate(R.layout.topic_list, null); TextView title = (TextView) convertView .findViewById(R.id.title); m.put(position, convertView); } }