안드로이드 개발 질문/답변
(글 수 45,052)
package com.akd;
import java.util.Timer; import java.util.TimerTask;
import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.Animation.AnimationListener; import android.widget.ImageView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
Animation anim;
ImageView img;
Handler handler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.layout_up);
anim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
img.setVisibility(View.INVISIBLE);
}
});
img = (ImageView)findViewById(R.id.ImageView01);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
handler.post(new Runnable() {
public void run() {
// TODO Auto-generated method stub
img.startAnimation(anim);
}
});
}
};
timer.schedule(task, 3000);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
}애니메이션에 리스너를 달았는데요
만약 이미지뷰가 굉장히 많다면,,, 일일이 그걸 컨트롤해줄수는 없을거 같습니다.
애니메이션을 사용한 (startAnimation) View객체를 리스너에서 참조할 수 있는 방법이 있을까요?
설명이 맞게 되었는지 모르겠네요 ㅎㅎ;;;
onEndAnimation 부분에 들어가는 내용을 좀 바꿀수 있는 방법이 있을지를 질문드리는 겁니다. ㅎ;;




이미지뷰를 레이아웃에 감싸서, 그 레이아웃을 안보이게 하는건 어떨까요?