I have a imageButton with some pic as its src. I want to switch from that pic to an animated .gif file when i click on image button. i am using android studio. I tried to use normal method onCLick="" in layout but it's not working. I am getting an still image everytime normal static image is coming up.
newon is gif image
public void buttonClick3(View v) {
SharedPreferences sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
Boolean e = sharedPreferences.getBoolean("clicked3", false);
if (!e) {
aButton3.setImageResource(R.drawable.newon);
toggleSound.start();
sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("clicked3", true);
editor.commit();
}
if(e){
aButton3.setImageResource(R.drawable.newoff);
sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor = sharedPreferences.edit();
editor.putBoolean("clicked3", false);
editor.commit();
toggleSound.start();
}
}