I would like to use an animated drawable to pause and Resume from that frame.
<https: //developer.android.com/reference/android/graphics/drawable/AnimationDrawable>
I also referred to the URL above, but SETVisible () starts animation from the beginning.
I looked at other things, but the contents were covered and could not be used as a reference.
Is there a way to pause using an image in the animation list?
'''
s.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chip1 = chip1 - point;
chip.setText1("chip : " + chip1);
animationDrawable1.start();
animationDrawable2.start();
animationDrawable3.start();
animationDrawable4.start();
animationDrawable5.start();
animationDrawable6.start();
animationDrawable7.start();
animationDrawable8.start();
animationDrawable9.start();
Thread thread;
if(v == s) {
stopRun = false;
thread = new Thread(String.valueOf(this));
thread.start();
//開始時間の取得
starttime = System.currentTimeMillis();
}
b1.setEnabled(true);
b2.setEnabled(true);
b3.setEnabled(true);
s.setVisibility(View.INVISIBLE);
}
});
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animationDrawable1.stop();
animationDrawable4.stop();
animationDrawable7.stop();
animationDrawable1.setVisible(false,false);
animationDrawable4.setVisible(false,false);
animationDrawable7.setVisible(false,false);
stopRun = true;
run();
droidImage1.setImageResource(getID1((int1)n)); //droidImage1に乱数で決まった数字に当たる画像をセットする
droidImage4.setImageResource(getID1((int1)n1));
droidImage7.setImageResource(getID1((int1)n2));
b1.setEnabled(false); //ボタンを押せなくする
if(b1.isEnabled() == false && b2.isEnabled() == false && b3.isEnabled() == false) { //ボタンがすべて押されたときjudgeメソッドを呼び出す
judge();
}
}
});
});
'''
Below is the xml file
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@drawable/star"
android:duration="120"/>
</animation-list>