I added animate method to OnItemClickListener()
on list view but I got this error:
Call requires API level 16 (current min is 14): android.view.ViewPropertyAnimator#withEndAction
I know that the withEndAction method was added in API Level 16, and older devices do not have it but I want use this animate or like this in my API. How can i do that?
listViewHome.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final View view1 = view;
final String item = (String) parent.getItemAtPosition(position);
view.animate().setDuration(2000).alpha(0).withEndAction(new Runnable(){
@Override
public void run() {
contacts.remove(item);
adapter.notifyDataSetChanged();
view1.setAlpha(1);
}
});
}
You should use a listener with an AnimatorListenerAdapter
. For Example... of course you should have a different behavior for SDK <16
and >=16
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
//code here
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.