CursorAdapter bindView方法获取更新的游标但不更新android 4.3 jellybean中的视图

时间:2014-01-21 07:28:54

标签: android android-cursoradapter

我正在使用加载程序管理器从数据库获取本地数据并尝试通过游标适配器在列表视图中显示

我的列表视图包含视频列表,并具有在重命名视频后重命名视频的功能

所有Android版本都运行良好,除了android 4.3 jellybean list item没有用重命名文本更新

我的newview和bindview方法如下

public void bindView(View convertView, Context ctx, Cursor cursor) {
    ViewHolder holder = (ViewHolder) convertView.getTag();
    final int id = cursor.getInt(ID);
    final float length = (float) (cursor.getLong(LENGTH) / (1024f * 1024f));
    final String name = cursor.getString(NAME);
    final String path = cursor.getString(PATH);
    final long time = cursor.getLong(DOWNLOAD_TIME);

    holder.title.setText(name);
    holder.length.setText(String.format("%.2f", length) + " Mb");
    if (time != -1) {
        SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy",
                Locale.ENGLISH);
        String date = formatter.format(new Date(time));
        holder.date.setText(date);
    }
}



@Override
public View newView(Context arg0, Cursor cursor, ViewGroup parent) {
    final View itemLayout = mInflater.inflate(
            R.layout.new_library_downloaded_item, parent, false);
    final ViewHolder holder = new ViewHolder();
    holder.length = (TextView) itemLayout.findViewById(R.id.length);
    holder.title = (TextView) itemLayout.findViewById(R.id.title);
    holder.date = (TextView) itemLayout.findViewById(R.id.date);
    holder.preview = (ImageView) itemLayout.findViewById(R.id.preview);
    holder.play = (ImageButton) itemLayout.findViewById(R.id.playBtn);
    holder.delete = (LinearLayout) itemLayout.findViewById(R.id.delete);
    holder.share = (LinearLayout) itemLayout.findViewById(R.id.share);
    itemLayout.setTag(holder);
    return itemLayout;
}

private class ViewHolder {
    TextView length;
    TextView title;
    TextView date;
    ImageView preview;
    ImageButton play;
    LinearLayout delete;
    LinearLayout share;
}

任何人都可以帮我吗?

0 个答案:

没有答案