I'm attempting to implement a Marquee HorizontalScrollView however I'm getting an error message stating FATAL EXCEPTION: main Unable to start activity java.lang.NullPointerException
at line 55:
s.fullScroll(HorizontalScrollView.FOCUS_LEFT);
I'm not sure exactly why this is happening. I've created/declared the HorizontalScrollView in XML:
<HorizontalScrollView
android:id="@+id/sc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:scrollbars="none" >
and attempted to start the scrolling process using:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HorizontalScrollView s =(HorizontalScrollView) findViewById(R.id.sc);
s.fullScroll(HorizontalScrollView.FOCUS_LEFT);
I got this far using this example:
HorizontalScrollView: auto-scroll to end when new Views are added?
However I am unsure why I am getting this fatal exception / NPE.
Suggestions/input is appreciated!
Logcat:
04-07 15:11:23.931: D/AndroidRuntime(11307): Shutting down VM
04-07 15:11:23.931: W/dalvikvm(11307): threadid=1: thread exiting with uncaught exception (group=0x41968ba8)
04-07 15:11:23.931: E/AndroidRuntime(11307): FATAL EXCEPTION: main
04-07 15:11:23.931: E/AndroidRuntime(11307): Process: com.test.app, PID: 11307
04-07 15:11:23.931: E/AndroidRuntime(11307): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.app/com.test.app.Cast}: java.lang.NullPointerException
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.os.Handler.dispatchMessage(Handler.java:102)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.os.Looper.loop(Looper.java:136)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-07 15:11:23.931: E/AndroidRuntime(11307): at java.lang.reflect.Method.invokeNative(Native Method)
04-07 15:11:23.931: E/AndroidRuntime(11307): at java.lang.reflect.Method.invoke(Method.java:515)
04-07 15:11:23.931: E/AndroidRuntime(11307): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-07 15:11:23.931: E/AndroidRuntime(11307): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-07 15:11:23.931: E/AndroidRuntime(11307): at dalvik.system.NativeStart.main(Native Method)
04-07 15:11:23.931: E/AndroidRuntime(11307): Caused by: java.lang.NullPointerException
04-07 15:11:23.931: E/AndroidRuntime(11307): at com.test.app.Cast.onCreate(Cast.java:55)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.Activity.performCreate(Activity.java:5231)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-07 15:11:23.931: E/AndroidRuntime(11307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-07 15:11:23.931: E/AndroidRuntime(11307): ... 11 more