나는 다음과 같은 코드 샘플 프로그램을 애니메이션을 시도하고있다 :애니메이션 드로어 블 AnimationDrawable
AnimationDrawable animation;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loading);
ImageView animatedImage = (ImageView) findViewById(R.id.animation);
animatedImage.setBackgroundResource(R.drawable.animate_bag);
animation = (AnimationDrawable) animatedImage.getBackground();
}
public void startAnimate(View v)
{
if (animation != null)
animation.start();
} //eof OnClick
XML 파일은 다음과 같습니다 내가 가진 문제가 있다는 것입니다
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Animate"
android:onClick="startAnimate" />
<ImageView
android:id="@+id/animation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/animate_bag" />
</LinearLayout>
animatedImage.getBackground()는 null을 반환합니다.
이
감사합니다, 사이먼이 당신을 도울 것입니다
안녕하세요. 나이가 들었지만 어떤 해결책을 찾았습니까? 감사 – Youssef