안드로이드 개발 질문/답변
(글 수 45,052)
Professional Android 어플리케이션 개발(빨간책) 507페이지를 보고 에니메이션을 만들었는데
10-22 06:44:31.580: ERROR/AndroidRuntime(811): java.lang.RuntimeException: Unable to start activity ComponentInfo{HelloFullCodeAndroid/HelloFullCodeAndroid.HelloFullCodeAndroid}: java.lang.NullPointerException와 같이 널포인터가 뜹니다.원인은10-22 06:44:31.580: ERROR/AndroidRuntime(811): Caused by: java.lang.NullPointerException이며
10-22 06:44:31.580: ERROR/AndroidRuntime(811): at HelloFullCodeAndroid.HelloFullCodeAndroid.onCreate(HelloFullCodeAndroid.java:39)
res/drawable/안에mwv0.png, mwv1.png, mwv2.png, loading_ani.xml 가 있습니다. xml의 내용은 아래와 같습니다.
자바 코드는<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"><item android:drawable="@drawable/mwv0" android:duration="500" /><item android:drawable="@drawable/mwv1" android:duration="500" /><item android:drawable="@drawable/mwv2" android:duration="500" /></animation-list>
public class HelloFullCodeAndroid extends Activity {/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 애니메
ImageView image = (ImageView)findViewById(R.layout.main);//my_ani_frm
image.setBackgroundResource(R.drawable.loading_ani);
AnimationDrawable animation = (AnimationDrawable)image.getBackground();
animation.start();}
}sdk 버전은 1.5로 했습니다.
공지사항을 다 읽었음
ImageView image = (ImageView)findViewById(R.layout.main);//my_ani_frm
이 코드가 잘못되어잇네요.
최촌에 setContentView로 레이아웃을 Inflate한 후에 findViewById로 View를 가져오셔야 합니다.