2012-07-24 87 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:/

相關問題