1
나는 스스로 안드로이드 개발을 공부하고있다. 갤러리를 사용할 때 문제가 있습니다. 코드는 다음과 같습니다.android gallery
Gallery cf=new Gallery(this);
cf.setSpacing(20);
cf.setAdapter(imageAdapter);
cf.setAnimationDuration(1500);
setContentView(cf);
하지만 시도 할 때 잘못되었습니다.
Gallery cf=(Gallery)this.findViewById(R.id.Gallery);
cf.setSpacing(20);
cf.setAdapter(imageAdapter);
cf.setAnimationDuration(1500);
setContentView(R.layout.display);
<Gallery
android:id="@+id/Gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:spacing="-60px"/
>
어떻게해야합니까?
편집 : 로그 캣 :
02-25 15:22:45.009: E/AndroidRuntime(500): FATAL EXCEPTION: main
02-25 15:22:45.009: E/AndroidRuntime(500): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vic.android.BluetoothContacts/com.vic.android.BluetoothContacts.PhotoDisplay}: java.lang.NullPointerException
02-25 15:22:45.009: E/AndroidRuntime(500): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-25 15:22:45.009: E/AndroidRuntime(500): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
정확히 어떤 문제가 시도 ? –
우리에게 Log Cat 오류 메시지와 stacktrace를 보내십시오. 우리는 당신의 마음이나 화면을 통해 볼 수있는 부두 사람들이 아닙니다. – AsTeR
감사합니다 .02-25 15 : 22 : 45.009 : E/AndroidRuntime (500) : 치명적인 예외 : 메인 02-25 15 : 22 : 45.009 : E/AndroidRuntime (500) : java.lang.RuntimeException : 활동을 시작할 수 없습니다. ComponentInfo {com.vic.android.BluetoothContacts/com.vic.android.BluetoothContacts.PhotoDisplay} : java.lang.NullPointerException 02-25 15 : 22 : 45.009 : E/AndroidRuntime (500) : \t android.app.ActivityThread .performLaunchActivity (ActivityThread.java:1647) 02-25 15 : 22 : 45.009 : E/AndroidRuntime (500) : \t android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:1663) – Vic