Tôi gặp sự cố khi sử dụng Hoạt ảnh trong Bộ điều hợp của mình.Sử dụng hoạt ảnh trong bộ chuyển đổi với mẫu ViewHolder
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(resource, parent, false);
holder = new ViewHolder();
holder.newRoomView = (TextView) convertView.findViewById(R.id.newRoom);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Room item = items.get(position);
// animate new rooms
if (item.isNewRoom()) {
AlphaAnimation alphaAnim = new AlphaAnimation(1.0f, 0.0f);
alphaAnim.setDuration(1500);
alphaAnim.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
holder.newRoomView.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
});
holder.newRoomView.startAnimation(alphaAnim);
}
// ...
return convertView;
}
Khi thêm một phòng mới bên ngoài của adapter và gọi notifyDataSetChanged
phòng mới được hoạt hình một cách chính xác, nhưng khi onAnimationEnd
được gọi, khác (phòng không mới) là ẩn.
Có cách nào để ẩn phòng chính xác không?
tại sao bạn không dùng thử bằng cách sử dụng 'RecyclerView'? –
đăng bố cục của mặt hàng của bạn, plz – SilentKnight