I am making an app that has a list of two items that have two gifs, one in each (the same gif). As you can see in the video, when you click on the gif, the gif is not shown in motion and it is shown as a solid image, but when you click the right or left arrow it is shown correctly in motion despite that the function to load the gif is called in both the OnCreate function and the btn_next.setOnClickListener() function and the btn_prev.setOnClickListener() function. So the same thing is done but onCreate() the gif is not shown in motion and on btn_next and btn_prev setOnClickListener() it is shown. Please, someone could tell me what could be happening here? Bcause actually the same code is executed but on the first clikc is not working Video: https://youtube.com/shorts/S5fDsqu3CeI?feature=share
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog);
init();
glide();
}
private void init() {
img_1 = findViewById(R.id.img_image1);
btn_prev = findViewById(R.id.dialog_btn_prev);
btn_next = findViewById(R.id.dialog_btn_next);
btn_next.setOnClickListener(view -> {
glide();
});
btn_prev.setOnClickListener(view -> {
glide();
}
});
}
public void glide() {
Glide.with(getApplicationContext()).load(R.drawable.earth).into(img_1);
}