이 질문은 여러 번 물어 볼 수는 있지만 문제를 해결할 수는 없습니다. 사용자 지정 ListView 데이터를 스크롤 할 때마다 위치가 잘못 배치 된 경우 Where else 조건. 제 실수를 알려주십시오.스크롤 할 때 ListView 데이터 위치가 잘못됨
공용 클래스 ImageAdapter를 사용하면 뷰를 만들 때 getItem()
에 첫 번째 호출에 전달 된 position
에 결합 setOnClickListener
에 의해 할당 청취자 내부 BaseAdapter {
private LayoutInflater mInflater;
public ImageAdapter(Context c) {
mInflater = LayoutInflater.from(c);
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.griddata, null);
k = position;
holder = new ViewHolder();
holder.txttitle = (TextView) convertView
.findViewById(R.id.txttitle);
holder.txtproduct = (TextView) convertView
.findViewById(R.id.txtproduct);
holder.txtcustname = (TextView) convertView
.findViewById(R.id.txtcustname);
holder.txtcompanyname = (TextView) convertView
.findViewById(R.id.txtcompanyname);
holder.txtaddress = (TextView) convertView
.findViewById(R.id.txtaddress);
holder.txttime = (TextView) convertView
.findViewById(R.id.txttime);
holder.txtrefid = (TextView)convertView.findViewById(R.id.txtrefid);
holder.btnphoto1 = (Button)convertView.findViewById(R.id.btnphoto1);
holder.btnphoto2 = (Button)convertView.findViewById(R.id.btnphoto2);
holder.btnsignpad = (Button)convertView.findViewById(R.id.btnsignature);
if (imgurl1list.get(position).equals("anyType{}")) {
holder.btnphoto1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
i = 1;
type = title.get(position).toString();
refid = v.getTag().toString();
selectedbutton = holder.btnphoto1;
selectImage();
}
});
}
else{
holder.btnphoto1.setText("Photo Exists");
}
if (imgurl2list.get(position).equals("anyType{}")) {
holder.btnphoto2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
i = 2;
type = title.get(position).toString();
refid = v.getTag().toString();
selectedbutton = holder.btnphoto2;
selectImage();
}
});
}
else{
holder.btnphoto2.setText("Photo Exists");
}
if (imgurl3list.get(position).equals("anyType{}")) {
holder.btnsignpad.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
type = title.get(position).toString();
refid = v.getTag().toString();
selectedbutton = holder.btnsignpad;
signpadselection();
}
});
}
else{
holder.btnsignpad.setText("Signature Exists");
}
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.txttitle.setText(title.get(position));
holder.txtrefid.setText(uniquerefid.get(position));
holder.txttitle.setTag(uniquerefid.get(position));
holder.txtaddress.setText(address.get(position));
holder.txtcustname.setText(customername.get(position));
holder.txtcompanyname.setText(companyname.get(position));
holder.txtproduct.setText(product.get(position));
holder.txttime.setText(createdon.get(position));
holder.btnphoto1.setTag(uniquerefid.get(position));
holder.btnphoto2.setTag(uniquerefid.get(position));
holder.btnsignpad.setTag(uniquerefid.get(position));
return convertView;
}
class ViewHolder {
TextView txttitle, txtcompanyname, txtproduct, txtcustname,
txtaddress, txttime, txtrefid;
Button btnphoto1, btnphoto2, btnsignpad;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return title.size();
}
}
답변 해 주셔서 감사합니다. 그러나 didnt 일 : ( –
@MayuriRuparel 당신은 업데이트 된 코드를 게시 할 수 있습니까? –