I used an android library to make a submit button with a nice animation (code below), after pressing the button, a want to start a new activity, but only after the animation is finished, how do i do that?
Xml code for the button "submitButton":
<com.spark.submitbutton.SubmitButton
android:layout_width="200dp"
android:layout_height="200dp"
android:text="Submit"
android:textColor="@color/gray"
app:sub_btn_background="@color/white"
app:sub_btn_duration="3000"
app:sub_btn_line_color="#99FF00"
app:sub_btn_ripple_color="#99FF00"
app:sub_btn_tick_color="@color/white"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/submitButton" />
Submit button for java file and action listener :
SubmitButton submitButton = (SubmitButton) findViewById(R.id.submitButton);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this,ListViewActivity.class));
}
});
If that custom button doesn't provide a listener for its animation, there's no way to know when its animation is done.
Alternatively, you could use the duration of that animation, and start your activity in a postDelayed(runnable, duration)
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(MainActivity.this,ListViewActivity.class));
}
}, duration);
You may also replace the new Handler()
with the v
from onClick(View v)