0

I found threads where people had troubles with invalidate because they were not on UI thread, calling sleep etc, but that doesn't apply to me. Code from onContextItemSelected, which runs on UI, right?

case CUT_ID:
            if(ldb.hasRights(meta.vpath)){
                RelativeLayout importBar = (RelativeLayout)findViewById(R.id.import_bar);
                RelativeLayout editBar = (RelativeLayout)findViewById(R.id.edit_bar);
                importBar.setVisibility(View.GONE);
                editBar.setVisibility(View.VISIBLE);
                clipboardVPath = meta.vpath;
                ImageView thumbView = (ImageView) info.targetView.findViewById(R.id.thumbview);
                thumbView.setImageResource(R.drawable.cut);
                gridView.invalidate();

The thumbView.setImageResource(R.drawable.cut); has the desired effect of replacing an item in a gridview by a scissors symbol. Problem arises when I select cut on another item. Now both have the cut drawable, while I allow only 1 item to be cut. This code in getView on my custom ThumnbnailAdapter should guarantee that the view I selected cut first on should revert to a bitmap from array thumbBitmaps:

if (thumbBitmaps.size() > position) {
                if(meta.vpath.equals(clipboardVPath)){
                    holder.img.setImageResource(R.drawable.cut);
                }else{
                    holder.img.setImageBitmap(thumbBitmaps.get(position));
                }   

            }

Whats wrong here?

4

1 回答 1

0

我需要的是 adapter.notifyDataSetChanged(); 我猜在无效时,gridview 询问它的孩子是否需要重绘,他们都回答不,因为他们认为他们的数据是最新的。这是我的猜测。

于 2012-07-09T16:38:07.073 回答