When I say gif, I mean any kind of short animation.
I have 2 Activities, the first asks a question and calculates the result, the second shows some points.
Well, what I would like to do is that once they answer in the first activity, before launching the second I want a gif to appear for 2 seconds. And then load the second activity. It's possible?
bt1.setOnClickListener(new AdapterView.OnClickListener() {
@Override
public void onClick( View view) {
if (bt1.getText().equals("" + res2)) {
bt1.setBackgroundResource(R.drawable.bt_true); aciertos++;
//Aqui quiero mostrar un gif
} else {
bt1.setBackgroundResource(R.drawable.bt_false); fallos++;
//Aqui quiero mostrar otro gif
}
siguienteActividad();
}
});
Just insert this code , Also put your gif inside the folder
/assets
(if you don't have the folder/assets
, create one belowsrc/main
)To wait 3 seconds and be able to do the
intent
use:In addition to @Bruno Sosa Fast Tag answer, you can use Glide library to load any
imagen
orGIF
in Android.Use Glide to load normal images, server images etc...
It doesn't actually "throw a .gif", what you want is to load an animated .gif and then make an intent to open a new Activity.
In addition to using a as Bruno Sosa
WebView
comments , you can also use aImageView
Using Glide to load an animated .gif inside a
ImageView
.After displaying the animated .gif you can start the following Activity
To show an animated .gif not only from the resources but also loading from an internet url, these are two options:
How to load an animated gif on Android