-1
여기에 제 코드가 있습니다. 문제는 if 조건이 충족 될 때 하나의 특정 애니메이션을 활성화하고자하는 것입니다. 내 코드를 통해이 작업을 수행 할 때 목표를 달성하기 위해 다른 모든 애니메이션을 개별적으로 닫아야 함을 알 수 있습니다.안드로이드 스튜디오에서 특정 애니메이션을 제외한 모든 애니메이션을 취소하는 방법
나는 이것을하기위한 깨끗한 방법인지 알고 싶습니다.
beaconManager = new BeaconManager(this);
beaconManager.setBackgroundScanPeriod(2000,20000);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
if (!list.isEmpty()) {
Beacon nearestBeacon = list.get(0);
int number = nearestBeacon.getMajor();
if(number == 1479)
{
Animation an = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.test);
blueButton.startAnimation(an);
yellowButton.clearAnimation();
blueButton2.clearAnimation();
orangeButton.clearAnimation();
orangeButton2.clearAnimation();
purpleButton.clearAnimation();
redButton.clearAnimation();
greenButton.clearAnimation();
}
if(number == 7574)
{
Animation an = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.test);
blueButton2.startAnimation(an);
blueButton.clearAnimation();
yellowButton.clearAnimation();
orangeButton.clearAnimation();
orangeButton2.clearAnimation();
purpleButton.clearAnimation();
redButton.clearAnimation();
greenButton.clearAnimation();
}
.
.
.
if(number == 61120)
{
Animation an = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.test);
yellowButton.startAnimation(an);
blueButton.clearAnimation();
blueButton2.clearAnimation();
orangeButton.clearAnimation();
orangeButton2.clearAnimation();
purpleButton.clearAnimation();
redButton.clearAnimation();
greenButton.clearAnimation();
}
}
}
});
region = new Region("ranged region", null, null, null);
}
답변 해 주셔서 감사합니다.하지만 불행히도 이것이 작동하지 않습니다. 나도 전에 이것을 시도했지만 anim.cancel()과 anim.reset() 후에 startAnimation을 다시 사용하면 내 프로그램이 원하는 애니메이션 만 표시하지 않고 전에 사용했던 모든 애니메이션을 표시합니다. :) – Andrew