-----------main activity-----------------
public void db(String todayStr){
allListDto=helper.selectList(todayStr);
/********progressbar********/
pBar=(ProgressBar) findViewById(R.id.progressBar1);
progTv=(TextView) findViewById(R.id.progInt);
int t_count=0;
int t_docount=0;
for (int i = 0; i < allListDto.size(); i++) {
t_count+=allListDto.get(i).getTo_count();
t_docount+=allListDto.get(i).getTo_docount();
}
if(t_count!=0 || t_docount!=0){
progInt=(t_docount*100)/t_count;
}else{
progInt=0;
}
pBar.setProgress(progInt);
progTv.setText(" : "+progInt+"%");
/***************************/
adapter=new CustomerAdapter(MainActivity.this, allListDto, R.layout.listviewunit);
list=(ListView) findViewById(R.id.listView1);
list.setAdapter(adapter);
Log.i("cursor", "db끝");
}
-------------customer adapter----------------------
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Log.e("cursor", "customer - getView");
if(convertView==null){
convertView=inflater.inflate(layout, parent, false);
}
ListDto listDto=allListDto.get(position);
ImageView[] oxArray={oxImg1,oxImg2,oxImg3,oxImg4,oxImg5,oxImg6,oxImg7,oxImg8,oxImg9,oxImg10}; //이미지 선언
int[] oxImg={R.id.oxImg1,R.id.oxImg2,R.id.oxImg3,R.id.oxImg4,R.id.oxImg5, //이미지 위치
R.id.oxImg6,R.id.oxImg7,R.id.oxImg8,R.id.oxImg9,R.id.oxImg10};
if(listDto.getTo_docount()<=0){
for (int i = 0; i < listDto.getTo_count(); i++) {
oxArray[i]=(ImageView)convertView.findViewById(oxImg[i]);
oxArray[i].setImageResource(R.drawable.x);
Log.e("cursor", "customer-for문"+Integer.toString(listDto.getTo_count()));
}
Log.e("cursor", "customer-if문"+Integer.toString(listDto.getTo_count()));
}else{
for (int i = 0; i < listDto.getTo_docount(); i++) {
oxArray[i]=(ImageView)convertView.findViewById(oxImg[i]);
oxArray[i].setImageResource(R.drawable.o);
}
for (int i = listDto.getTo_docount(); i < listDto.getTo_count(); i++) {
oxArray[i]=(ImageView)convertView.findViewById(oxImg[i]);
oxArray[i].setImageResource(R.drawable.x);
}
}
TextView to_do=(TextView) convertView.findViewById(R.id.todo);
to_do.setText(listDto.getTo_do());
TextView to_unit=(TextView) convertView.findViewById(R.id.tounit);
to_unit.setText(listDto.getTo_unit());
return convertView;
}
----------------log cat-------------------
02-05 01:25:08.609: I/cursor(1540): db끝
02-05 01:25:09.409: E/cursor(1540): customer - getView
02-05 01:25:09.509: E/cursor(1540): customer-for문2
02-05 01:25:09.509: E/cursor(1540): customer-for문2
02-05 01:25:09.509: E/cursor(1540): customer-if문2
02-05 01:25:09.719: E/cursor(1540): customer - getView
02-05 01:25:09.719: E/cursor(1540): customer-for문2
02-05 01:25:09.729: E/cursor(1540): customer-for문2
02-05 01:25:09.729: E/cursor(1540): customer-if문2
02-05 01:25:09.929: E/cursor(1540): customer - getView
02-05 01:25:10.019: E/cursor(1540): customer-for문2
02-05 01:25:10.019: E/cursor(1540): customer-for문2
02-05 01:25:10.029: E/cursor(1540): customer-if문2
02-05 01:25:11.179: E/cursor(1540): customer - getView
02-05 01:25:11.179: E/cursor(1540): customer-for문2
02-05 01:25:11.190: E/cursor(1540): customer-for문2
02-05 01:25:11.209: E/cursor(1540): customer-if문2
02-05 01:25:11.739: E/cursor(1540): customer - getView
02-05 01:25:11.770: E/cursor(1540): customer-for문2
02-05 01:25:11.770: E/cursor(1540): customer-for문2
02-05 01:25:11.779: E/cursor(1540): customer-if문2
02-05 01:25:12.809: E/cursor(1540): customer - getView
todolist를 만들었는데요..
리스트가 있고 입력된 수만큼 o x표시를 해줄수있게 만들었거든요..
근데 첫번째줄 x갯수가 새로 입력한 갯수랑 자꾸 같아져서 로그를 찍어보니까...
위에처럼 db메소드를 분리하고 oncreate에서 db메소드를 호출하는데요 customer adapter에서 뭔가 작업이 끝나지가 않는건지.. 계속 반복이 되고있어요..
아직 입문단계라... 원래 이런건지.. 뭐가 문제인건지 모르겠어요..ㅜㅜ
customer adapter는 결과 반환하면 작업이 끝나는게 아닌가요??