ExpandableListView에 큰 문제가 있습니다. 내 목표는이 단일 선택 확장 목록보기에 사용자 변경 항목의 위치를 수 있도록하는 것입니다 : 체크 표시된 항목을 확장 가능한 목록보기로 이동
사용자가 항목을 클릭
이 항목이 선택되고 상황에 맞는 작업 표시 줄이 나타납니다. 그래서 사용자가 이동하거나이 방법의 항목 아래 수 있습니다내가 잘 (가 ArrayList에 이상 스왑 위치에 따라 작품 구현 한 움직임 업/다운 기능, 즉의 데이터 소스의 내 BaseExpandableListAdapter 및 UI 변경 사항을 알립니다. 불행히도 내가 체크 항목을 이동하면 체크 상태를 잃어버린 ... 그리고 내가 (예를 들어, "잠금"또는 "Attachements"보기 전에) 보이는 가시 범위 밖으로 항목을 이동하면 expandablelistview 스크롤하지 않습니다 새로운 위치.
어떻게 할 수 있습니까?
다음, 내 "moveDownFocusedItem()가"내 사용자 지정 어댑터 클래스로 코딩 :
//This class is ok!
//Contains Group and Child position of an ExpandableListView
public class Position{
int GroupPosition;
int ChildPosition;
public boolean isChild(){
return (ChildPosition != AbsListView.INVALID_POSITION);
}
public Position getPreviousPosition(){
if(ChildPosition==AbsListView.INVALID_POSITION)
if(GroupPosition>0)
return new Position(GroupPosition-1);
else
return null;
else
if(ChildPosition>0)
return new Position(GroupPosition, ChildPosition-1);
else
return null;
}
public Position getNextPosition(){
if(ChildPosition==AbsListView.INVALID_POSITION)
if(GroupPosition<_fieldConfigurationList.size()-1)
return new Position(GroupPosition+1);
else
return null;
else
if(ChildPosition<_fieldConfigurationList.get(GroupPosition).getChildren().size()-1)
return new Position(GroupPosition, ChildPosition+1);
else
return null;
}
public Position(int groupPosition){
this.GroupPosition = groupPosition;
this.ChildPosition = AbsListView.INVALID_POSITION;
}
public Position(int groupPosition, int childPosition){
this.GroupPosition = groupPosition;
this.ChildPosition = childPosition;
}
}
public void moveDownFocusedItem(){
//This function returns the next position to move to
//(_focusedPosition is the current checked item position)
Position nextPosition = this._focusedPosition.getNextPosition();
//Swap ArrayList (This works!)
if(nextPosition!=null){
Collections.swap(this._fieldConfigurationList, //that's my datasource
this._focusedPosition.GroupPosition, //Start position for swapping
nextPosition.GroupPosition); //Destination position for swapping
//Set the new focused position (This works!)
this._focusedPosition = nextPosition;
//TODO:
//Now i have to call "SetItemChecked()" method to uncheck old focused position and check the new one.
//How to do it? How can i get the required "position" argument from _focusedPosition.GroupPosition and _focusedPosition.ChildPosition?
//And also...if the focused view has moved to an invisible position (such as the end of the expandablelistview) how can i scroll
//to this position?
//Notify changes (This works!)
this.notifyDataSetChanged();
}
}