아...
ListView를 만들때 Apdater내 getView에서 작은 이미지를 추가 해줬습니다.
실행을 하면 추가된 아이콘이 정상적으로 보입니다.
그런데..
스크롤을 움직일 경우
생성된 이미지가 다른곳에도 생겨 보여지네요.
getView()메서드가 스크롤 움직일때마다 계속 호출이 되는데
이걸 어찌 잡아야 하는지요? 어찌 이런 일이 생기는지 많이 당황스럽네요..
버그인지??
혹시나 해서 ListView 말고 RecyclerView로 변경을 했지만... 동일 증상이 나타나는군요.
인터넷 뒤져보니 xml 디자인 화면에서 높이를 wrap_content로 지정해준것 때문이라고 하는데..
수정해줘도 변화가 없네요..ㅜㅜ
뭐가 문제인가요??
PS. 추가내용 입니다.
getView() 내용은 다음과 같습니다.
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if(convertView == null) {
convertView = inflater.inflate(this.layout, parent, false);
}
TextView tv_day = (TextView) convertView.findViewById(R.id.tv_day);
ImageView iv_icon = (ImageView) convertView.findViewById(R.id.iv_weather);
TextView tv_comment = (TextView) convertView.findViewById(R.id.tv_comment);
Button bt_select = (Button) convertView.findViewById(R.id.bt_select);
tv_day.setText(data.get(position).getDay() + " | ");
iv_icon.setImageResource(data.get(position).getIcon());
tv_comment.setText(data.get(position).getComment());
// 배경색 변경
if((position) == 5) {
convertView.setBackgroundColor(0x5000ff00);
}
위 소스중 배경색 이라는 주석부분을 저렇게 넣어주면
해당 5번 라인에 배경색이 들어 갑니다. 그런데 스크롤을 위/아래로 움직이면
배경색이 5번 라인에만 있어야 하는데 다른 부분까지 배경색이 들어 갑니다..
이 문제를 어찌 해결해야 할까요?
몇일째 이 문제로 고민 입니다... 아시는분의 손길을 손꼽아 기다리오니.. 한수 부탁드립니다..