i have got this problem in my code, that when a make a transition on one button in viewholder which is done in Onclicklistener, multiple transition occurs on different rows i.e if i click on button in row 1 then the button moves right which is expected, but button in row 6 also moves right which is not expected. i have checked that the transition ID of button in Row 1 is same as Button is Row 6 i don't know, what is wrong with my code. please help. check my code.
public class UserCustomAdapter extends ArrayAdapter<User> {
Context context;
int layoutResourceId;
ArrayList data = new ArrayList();
String weekDay;
AlertDialog alert;
public UserCustomAdapter(Context context, int layoutResourceId,
ArrayList<User> data, String weekDay) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
this.weekDay = weekDay;
}
@Override
public View getView(final int position, final View convertView, final
ViewGroup parent) {
View row = convertView;
final UserHolder holder;
if (row == null) {
LayoutInflater inflater1 = ((Activity) context).getLayoutInflater();
row = inflater1.inflate(layoutResourceId, parent, false);
holder = new UserHolder();
holder.subject = (TextView) row.findViewById(R.id.subject);
holder.percentage = (TextView) row.findViewById(R.id.percentage_edit);
holder.attended = (Button) row.findViewById(R.id.attended);
holder.bunked = (Button) row.findViewById(R.id.bunked);
holder.other = (Button) row.findViewById(R.id.other);
row.setTag(holder);
}
else {
holder = (UserHolder) row.getTag();
}
//to set the text into the fields
User user = (User) data.get(position);
holder.subject.setText(user.getName());
holder.percentage.setText(user.getAddress());
holder.attended.setId(position);
holder.bunked.setId(position);
holder.other.setId(position);
holder.attended.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// FOR ANIMATIONS OF BUTTONS
TranslateAnimation translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.28f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
translate.setDuration(600);
holder.attended.startAnimation(translate);
Log.d("trans", holder.attended + "");
translate.setFillAfter(true);
TranslateAnimation translate1 = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
translate1.setDuration(600);
holder.other.startAnimation(translate1);
translate1.setFillAfter(true);
TranslateAnimation translate2 = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
translate2.setDuration(600);
holder.bunked.startAnimation(translate2);
translate2.setFillAfter(true);
}
});
return row;
}
static class UserHolder {
TextView subject;
TextView percentage;
Button attended;
Button bunked;
Button other;
}
}