ListView 목록 새로고침 : adapter.notifyDataSetChanged()
참조 소스)
ByReqListAdapter adapter = null;
ArrayList<SearchUpbunUnit> arMansInfo = new ArrayList<SearchUpbunUnit>(); //검색 리스트
ListView lvSubByReq1 = null;
int iResultStart = -5;
int iResultEnd = 5;
.....
lvSubByReq1 = (ListView)findViewById(R.id.lvSubByReq);
lvSubByReq1.setVisibility(View.VISIBLE);
adapter = new ByReqListAdapter(getContext(), R.id.lvSubByReq1, arMansInfo);
lvSubByReq1.setAdapter(adapter);
//리스트뷰의 목록을 셋팅
lvSubByReq1.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if ((firstVisibleItem + visibleItemCount) == totalItemCount) {
Log.v(TAG, "IN, totalItemCount = " + totalItemCount);
//결과값이 널이면 리턴
if(arWorkProc==null){ return; }
//결과를 다 출력했으면 더 출력하지 않는다.
if(iResultEnd == arWorkProc.size())return;
//시작점 계산
if((iResultStart+5)>=arWorkProc.size()){
iResultStart = arWorkProc.size();
}else{
if(iResultStart==-5){
iResultStart = 0;
}else{
iResultStart = iResultEnd;
}
}
//끝점 계산
if((iResultEnd+5)>=arWorkProc.size()){
iResultEnd = arWorkProc.size();
}else{
iResultEnd = iResultEnd + 5;
}
//결과를 출력해
outputResult();
}
}
});
.....
//결과를 출력
public synchronized void outputResult(){
Log.i(TAG, ">outputResult : start("+iResultStart+"), end("+iResultEnd+")");
for(int i=iResultStart; i<iResultEnd; i++){
try{
Log.i(TAG, ">outputResult : idx : " + i);
HashMap hmUnit = (HashMap)arWorkProc.get(i);
String sUnitUpbunAddr =
com.util.StringUtil.Nvl((String)hmUnit.get("record1")); //결과항목1
String sUnitZipcode = com.util.StringUtil.Nvl((String)hmUnit.get("record2")); //결과항목2
String sUnitBjMoney = com.util.StringUtil.Nvl((String)hmUnit.get("record3")); //결과항목3
String sUnitProcState = com.util.StringUtil.Nvl((String)hmUnit.get("record4")); //결과항목4
String sUnitExpireDate =
com.util.StringUtil.Nvl((String)hmUnit.get("expire_date"));
//결과항목5
//데이타들 추가
SearchUpbunUnit temp;
temp = new SearchUpbunUnit(i+"", sUnitUpbunAddr, sUnitZipcode,
sUnitBjMoney, sUnitProcState, sUnitExpireDate, "", "");
arMansInfo.add(temp);
//refresh
adapter.notifyDataSetChanged();
}catch(Exception e){
Log.i(TAG, ">outputResult : Exception : " + e.toString());
}
}
}
즐거운 시간 보내세요~
댓글 없음:
댓글 쓰기