2012-07-24 89 views
0

好吧,我有一个自定义AdapterView。每当我检测到长时间点击时,我都会调用一种方法来更改自定义的可编辑状态。自定义适配器视图没有正确更新

public void setEditing(boolean editing) { 
    this.editing = editing; 
    //Set editing to children 
    for (int i=0; i < getChildCount(); i++){ 
     ((PresentationPickerGalleryCellView)getChildAt(i)).setEditing(editing); 
     if (editing == true) 
      getChildAt(i).setVisibility(View.INVISIBLE); 
      //((PresentationPickerGalleryCellView)getChildAt(i)).deleteImageButton.setVisibility(View.VISIBLE); 
    } 
} 

就我而言,它在主线程中执行。 现在,如果我叫:

getChildAt(i).setVisibility(View.INVISIBLE); 

它编辑时隐藏整个视图正确 ==真。但如果我打电话:

((PresentationPickerGalleryCellView)getChildAt(i)).deleteImageButton.setVisibility(View.VISIBLE); 

deleteImageButton是单元格内的按钮。 它不会在所有处显示deleteImageButton。我尝试invalidate,postInvalidate,布局,requestLayout,refreshDrawableState,但没有...

任何想法?

+0

如果您不让全部细胞可见?如果单元格不可见,那么仅使单元格内的按钮可见将无济于事。 – Gogu 2012-07-24 09:04:23

+0

当然,整个细胞是可见的。我只是测试隐藏整个单元格或在单元格内显示按钮的区别 – Lupi 2012-07-24 09:11:48

回答

0

好的... 看来,如果我在开始时设置View.GONE,然后我尝试设置View.VISIBLE,它将不会显示按钮... 我只能使用View。 INVISIBLE和View.VISIBLE:/

相关问题