2014-04-17 1 views
0

에 초점을 맞춘 아이를 그립니다, 그래서 나는이 같은 CustomDrawingOrderTableRow 구현 :안드로이드 TableLayout을의 DrawingOrder는 : 내가 초점을 맞춘 항목 형제에 중복 것이다 하이라이트 배경을 만들고 싶어 내 레이아웃의 마지막

public class CustomDrawingOrderTableRow extends TableRow{... 

super.setChildrenDrawingOrderEnabled(true); 
... 

protected int getChildDrawingOrder(int childCount, int currentPos) { 
    return Util.getFocusedChildDrawLastOrder(this, childCount, currentPos); 
} 


    Uitl.java: 
public static int getFocusedChildDrawLastOrder(ViewGroup vg, 
     int childCount, int iter) { 
    View focusedView = vg.getFocusedChild(); 
    if (focusedView == null) {// no focused child 
     return iter; 
    } 
    // index of the focused child 
    int index = vg.indexOfChild(focusedView); 
    if (iter == childCount - 1) {// last draw the focused child 
     return index; 
    } else if (iter >= index) { 
     // Move the children after the focused child earlier one 
     return iter + 1; 
    } else { 
     // Keep the children before the focused child the same 
     return iter; 
    } 
} 

하지만를 집중된 자식인지 여부에 관계없이 그리기 순서는 변경되지 않습니다.

Tablelayout에서 포커스 된 자식 그리기를 끝내는 방법은 무엇입니까?

답변

0

문제의 코드가 맞습니다. 문제는 코드가 실행되지 않았기 때문입니다.

드디어 내가 전체 contianer 다시 무승부를 만들기 위해 OnFocusChangeListener에

parentContainer.requestLayout(); 

전화를해야하기 때문에 문제의 코드가 실행됩니다 알아낼.

관련 문제