Android -- ExpandbleView 원본 학습 --- expandableListPosition 클래스
3227 단어 position
ExpandbaleListPosition 클래스 는 group 의 위치 나 child 의 위 치 를 가리 킬 수 있 습 니 다.obtainChildPosition (int, int) 과 obtainGroupPosition (int) 을 통 해 인 스 턴 스 를 얻 을 수 있 습 니 다.
/**
* type 에 따라 groupPosition 또는 childPosition 의 형식 이 64 비트 인 데 이 터 를 되 돌려 줍 니 다.
**/
long getPackedPosition() {
if (type == CHILD) return ExpandableListView.getPackedPositionForChild(groupPos, childPos);
else return ExpandableListView.getPackedPositionForGroup(groupPos);
}
//
static ExpandableListPosition obtain(int type, int groupPos, int childPos, int flatListPos) {
ExpandableListPosition elp = getRecycledOrCreate();
elp.type = type;
elp.groupPos = groupPos;
elp.childPos = childPos;
elp.flatListPos = flatListPos;
return elp;
}
< pre class = "java" name = "code" > / 대상 초기 화 < / pre >
private void resetState() {
groupPos = 0;
childPos = 0;
flatListPos = 0;
type = 0;
}
/ / ExpandableListPosition 을 되 돌려 줍 니 다. 풀 에 대상 이 있 으 면 풀 에 대상 을 되 돌려 주 고 이 대상 을 제거 합 니 다 (초기 화 됩 니 다). 없 으 면 새 new 대상 을 되 돌려 줍 니 다.
private static ExpandableListPosition getRecycledOrCreate() {
ExpandableListPosition elp;
synchronized (sPool) {
if (sPool.size() > 0) {
elp = sPool.remove(0);
} else {
return new ExpandableListPosition();
}
}
elp.resetState();
return elp;
}
/ / 풀 에 ExpandableListPosition 대상 추가
public void recycle() {< pre class = "java" name = "code" > / ExpandableListPosition 대상 을 가 져 옵 니 다 < / pre >
synchronized (sPool) {
if (sPool.size() < MAX_POOL_SIZE) {
sPool.add(this);
}
}
}
static ExpandableListPosition obtain(int type, int groupPos, int childPos, int flatListPos) {
ExpandableListPosition elp = getRecycledOrCreate();
elp.type = type;
elp.groupPos = groupPos;
elp.childPos = childPos;
elp.flatListPos = flatListPos;
return elp;
}
/ / group 형식의 ExpandableListPosition 대상 가 져 오기
static ExpandableListPosition obtainGroupPosition(int groupPosition) {
return obtain(GROUP, groupPosition, 0, 0);
}
< pre class = "java" name = "code" > / / child 형식의 ExpandableListPosition 대상 획득
static ExpandableListPosition obtainChildPosition(int groupPosition, int childPosition) { return obtain(CHILD, groupPosition, childPosition, 0); }< pre class = "java" name = "code" > / 위치 에 따 른 패 키 징 데이터 로 위 치 를 얻 는 ExpandbaleListPostion static ExpandableListPosition obtainPosition (long packed Position) {if (packed Position = = ExpandableListView. PACKED POSITION VALUE NULL) {return null;} ExpandableListPosition elp = getRecycledOrCreate (); elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition); if (ExpandableListView.getPackedPositionType(packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { elp.type = CHILD; elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition); } else { elp.type = GROUP; } return elp; }
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WIL-CSS [Position]💡 position은 '위치'란 뜻으로 요소들의 위치를 지정해주는 속성이다. 💡 static은 position의 기본값이다. 기본적으로 특정한 position값을 주지 않으면 static값을 가지게 된다. 그래서 h...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.