1、 通常优化listview的adapter
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
final ReadInfo readinfo = mList.get(position);
if (convertView == null) {
convertView = inflater.inflate(R.layout.english_item, null);
holder = new ViewHolder();
holder.tv = (TextView) convertView.findViewById(R.id.tv);
holder.bt_stop = (Button) convertView.findViewById(R.id.stop);
holder.bt_play = (Button) convertView.findViewById(R.id.play);
holder.bt_record = (Button) convertView.findViewById(R.id.record);
holder.scoreTv = (TextView) convertView.findViewById(R.id.score);
holder.result = (TextView) convertView.findViewById(R.id.result);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//获取对象
if(有值){
//显示
}else{
//控件隐藏
}
}
2、如果动态更新某条数据后更新数据源
//刷新适配器
readAdapter.notifyDataSetChanged();
3、刷新出现数据错乱,是因为adapter加载的布局文件可见,复用布局的时候会出现已经用过的convertView的话就出现上个界面绘制的布局
此时操作,是绘制每一个都加上判断
如果有数据就显示,没数据就把控件隐藏就ok。
4、记录下,下次遇到该问题就好非常处理。