Note that there are some explanatory texts on larger screens.

plurals
  1. POApp crashes whenn setting an onClickListener?
    primarykey
    data
    text
    <p>Hi everybody I'm struggling a strange problem. I changed my ViewFlipper to ViewPager and since there my App crashed. I found out that it's not the Viewpager that crashes but the button.setOnClickListener method. I commented out everything else so I noticed that the App works fine if I'm commenting out my two Buttons with that method. And it's not the thing inside onClick(), I treied it out and it crashes even if it's empty.but here is some code of the one im fighting with:</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MyPagerAdapter adapter = new MyPagerAdapter(); ViewPager myPager = (ViewPager)findViewById(R.id.pager); myPager.setAdapter(adapter); myPager.setCurrentItem(1); new Toolbox(); push = (Button)findViewById(R.id.pushbutton); push.setOnClickListener(new OnClickListener() { public void onClick(View v) { head=head_field.getText().toString(); note=note_field.getText().toString(); try { Toolbox.createTask(userToken,task, Dashboard_id, head, note, service); head_field.setText(""); note_field.setText(""); } catch (ProducteevException e) { return; } } }); </code></pre> <p>this is the button xml excerpt:</p> <pre><code>&lt;Button android:id="@+id/pushbutton" android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center_horizontal" android:layout_marginTop="35dp" android:background="@drawable/push_button" /&gt; </code></pre> <p>and here the LogCat</p> <pre><code>01-12 20:50:24.402: W/dalvikvm(28405): threadid=1: thread exiting with uncaught exception (group=0x40015578) 01-12 20:50:24.402: E/AndroidRuntime(28405): FATAL EXCEPTION: main 01-12 20:50:24.402: E/AndroidRuntime(28405): java.lang.RuntimeException: Unable to start activity ComponentInfo{producteev.push/producteev.push.Producteev_pushActivity}: java.lang.NullPointerException 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.os.Handler.dispatchMessage(Handler.java:99) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.os.Looper.loop(Looper.java:123) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.ActivityThread.main(ActivityThread.java:3687) 01-12 20:50:24.402: E/AndroidRuntime(28405): at java.lang.reflect.Method.invokeNative(Native Method) 01-12 20:50:24.402: E/AndroidRuntime(28405): at java.lang.reflect.Method.invoke(Method.java:507) 01-12 20:50:24.402: E/AndroidRuntime(28405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 01-12 20:50:24.402: E/AndroidRuntime(28405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 01-12 20:50:24.402: E/AndroidRuntime(28405): at dalvik.system.NativeStart.main(Native Method) 01-12 20:50:24.402: E/AndroidRuntime(28405): Caused by: java.lang.NullPointerException 01-12 20:50:24.402: E/AndroidRuntime(28405): at producteev.push.Producteev_pushActivity.onCreate(Producteev_pushActivity.java:122) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 01-12 20:50:24.402: E/AndroidRuntime(28405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 01-12 20:50:24.402: E/AndroidRuntime(28405): ... 11 more </code></pre> <p>Would be amazing if somebody knows that Problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload