我只是想更好地理解我经常用来优化的以下模式ListView
我的阅读只指出静态内部类被视为顶级类的事实。与成员类(非静态)相比,这样的事情有什么好处?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Comment comment = getItem(position);
ViewHolder holder;
if (convertView == null){
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.mylayout, null);
holder.nickname = (TextView) ((ViewGroup) convertView).findViewById(R.id.nickname);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
holder.nickname.setText(comment.getMember_nickname());
CharSequence
return convertView;
}
public static class ViewHolder{
TextView nickname;
}