Note that there are some explanatory texts on larger screens.

plurals
  1. POI get an error doing a CountDown
    text
    copied!<p>i am Newbie and i am receiving errors and i don´t know why D:</p> <p>When i press Button my app crashes. Here my code: </p> <p>I tried different versions of countdowns and no one runs D: Thanks...</p> <p><strong>MainActivity</strong></p> <pre><code> package com.example.chrontest; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button Start = (Button) findViewById(R.id.button1); Start.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { Jungle CuentaAtras = new Jungle(6000, 1000); CuentaAtras.start(); }}); } } </code></pre> <p><strong>Jungle.class</strong></p> <pre><code> package com.example.chrontest; import android.os.CountDownTimer; import android.widget.TextView; public class Jungle extends CountDownTimer{ TextView Texto = (TextView) findViewById(R.id.textView1); public Jungle(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); // TODO Auto-generated constructor stub } private TextView findViewById(int textview1) { // TODO Auto-generated method stub return null; } @Override public void onFinish() { // TODO Auto-generated method stub Texto.setText("GAME OVER"); } @Override public void onTick(long millisUntilFinished) { Texto.setText ("" + millisUntilFinished / 1000); } } </code></pre> <p><strong>And here my LogCat:</strong></p> <pre><code>12-03 04:13:41.175: D/gralloc_goldfish(1395): Emulator without GPU emulation detected. 12-03 04:13:52.325: D/AndroidRuntime(1395): Shutting down VM 12-03 04:13:52.325: W/dalvikvm(1395): threadid=1: thread exiting with uncaught exception (group=0x41465700) 12-03 04:13:52.345: E/AndroidRuntime(1395): FATAL EXCEPTION: main 12-03 04:13:52.345: E/AndroidRuntime(1395): java.lang.NullPointerException 12-03 04:13:52.345: E/AndroidRuntime(1395): at com.example.chrontest.Jungle.onTick(Jungle.java:28) 12-03 04:13:52.345: E/AndroidRuntime(1395): at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:124) 12-03 04:13:52.345: E/AndroidRuntime(1395): at android.os.Handler.dispatchMessage(Handler.java:99) 12-03 04:13:52.345: E/AndroidRuntime(1395): at android.os.Looper.loop(Looper.java:137) 12-03 04:13:52.345: E/AndroidRuntime(1395): at android.app.ActivityThread.main(ActivityThread.java:5103) 12-03 04:13:52.345: E/AndroidRuntime(1395): at java.lang.reflect.Method.invokeNative(Native Method) 12-03 04:13:52.345: E/AndroidRuntime(1395): at java.lang.reflect.Method.invoke(Method.java:525) 12-03 04:13:52.345: E/AndroidRuntime(1395): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 12-03 04:13:52.345: E/AndroidRuntime(1395): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 12-03 04:13:52.345: E/AndroidRuntime(1395): at dalvik.system.NativeStart.main(Native Method) 12-03 04:13:53.925: I/Process(1395): Sending signal. PID: 1395 SIG: 9 </code></pre> <p><strong>UPDATED:</strong></p> <p>Lol i don´t put my layout, and.. today i see that i don´t have a view or anything to see my countdown, or just this will appear in the screen, lol i don´t know :|</p> <p>This is my layout:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_marginBottom="34dp" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:text="Button" /&gt; &lt;/RelativeLayout&gt; </code></pre>
 

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