Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid app crashing: code posted
    primarykey
    data
    text
    <p>hey i haave been searching for a while now and have tried multiple times to solve an error at updateUI();. I cant get it to work, the app keeps on crashing at launch. The code is posted</p> <p>"Unable to start activity <strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>___</strong> java.lang.NullPointerException"</p> <pre><code>public class MainActivity extends SherlockFragmentActivity { private TextView txtStatus; private ImageView imageView; int i=0; int imgid[]={R.drawable.new_york_city_1,R.drawable.facebook,R.drawable.groupsms,R.drawable.twittersms }; RefreshHandler refreshHandler=new RefreshHandler(); class RefreshHandler extends Handler{ @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub MainActivity.this.updateUI(); } public void sleep(long delayMillis){ this.removeMessages(0); sendMessageDelayed(obtainMessage(0), delayMillis); } }; public void updateUI(){ int currentInt=Integer.parseInt((String)txtStatus.getText())+10; if(currentInt&lt;=100){ refreshHandler.sleep(2000); txtStatus.setText(String.valueOf(currentInt)); if(i&lt;imgid.length){ imageView.setImageResource(imgid[i]); i++; } } }@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_main); SpannableString s = new SpannableString("DJUICE"); s.setSpan(new TypefaceSpan(this, "djuice"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(s); this.txtStatus=(TextView)this.findViewById(R.id.textViewM); this.imageView=(ImageView)this.findViewById(R.id.imageViewM); updateUI(); } </code></pre> <p>XML:</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:paddingLeft="4dp" android:paddingRight="4dp" android:paddingTop="4dp" android:paddingBottom="4dp" android:background="#FFFFFF"&gt; &lt;TextView android:text="10" android:id="@+id/textViewM" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt;&lt;/TextView&gt; &lt;ImageView android:id="@+id/imageViewM" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt;&lt;/ImageView&gt;&lt;/RelativeLayout&gt; </code></pre> <p>Logcat:</p> <pre><code>E/AndroidRuntime( 4898): FATAL EXCEPTION: main E/AndroidRuntime( 4898): java.lang.RuntimeException: Unable to start activity ComponentInfo{runaway.fridge.potohar/runaway.fridge.potohar.MainActivity}: java.lang.NullPointerException E/AndroidRuntime( 4898): at runaway.fridge.potohar.MainActivity.updateUI(MainActivity.java:59) E/AndroidRuntime( 4898): at runaway.fridge.potohar.MainActivity.onCreate(MainActivity.java:85) </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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