I have Button
which function is to animate one of my ImageView
for a second and delete specific table, recreate and insert the default value
. Everything's working fine but one of my requirements is to show the animation aleast 1 second even recreating table is done. how can i achieve this?
NOTE: I animate my ImageView
with Rotate effect so it will looks like refreshing.
refreshDatabase function
public void refreshDatabase(View v){
Button btnRefresh = (Button)findViewById(R.id.btnRef);
ImageView refreshing = (ImageView) findViewById(R.id.rfs);
btnRefresh.setClickable(false);
btnRefresh.setEnabled(false);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate);
//I want to start animation here
refreshing.startAnimation(animation);
....recreat table here
//Stop animation after 1 second
refreshing.clearAnimation();
}
rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<rotate
android:duration="300"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
</set>
I try to add this,
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//recreate table here
refreshing.clearAnimation();
}
}, 1000);
but i got an error Handler is abstract; cannot be instantiated
.
Anybody can help me? Thank You!!!