Problems with threads and progress dialog
<p>I'm trying to implement a progress dialog however I'm always getting a NullPointerException. This is a piece of my code:</p>

<pre><code>ProgressDialog MyDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.allshows);
    MyDialog = ProgressDialog.show(AllShowsActivity.this, " ", "Loading, please wait...", true);

    Thread thread = new Thread(this);
    thread.start();

}

public void run(){
...

    handler.sendEmptyMessage(0);
}

private Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        System.out.println("Being dismissed...");
        MyDialog.dismiss();
    }
};
</code></pre>

<p>Any thoughts? It all works well without the progress dialog so I guess what's inside the thread is not relevant. The log error is:</p>

<pre><code>07-19 15:45:58.010: ERROR/AndroidRuntime(3186): FATAL EXCEPTION: main
07-19 15:45:58.010: ERROR/AndroidRuntime(3186): java.lang.NullPointerException
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.AbsListView$RecycleBin.getScrapView(AbsListView.java:5698)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.AbsListView.obtainView(AbsListView.java:1940)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1228)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.ListView.onMeasure(ListView.java:1139)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.View.measure(View.java:10835)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:613)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:519)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.View.measure(View.java:10835)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:267)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.View.measure(View.java:10835)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:764)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:519)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.View.measure(View.java:10835)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:267)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:1890)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.View.measure(View.java:10835)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.ViewRoot.performTraversals(ViewRoot.java:915)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.view.ViewRoot.handleMessage(ViewRoot.java:2009)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.os.Looper.loop(Looper.java:132)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at android.app.ActivityThread.main(ActivityThread.java:4025)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at java.lang.reflect.Method.invokeNative(Native Method)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at java.lang.reflect.Method.invoke(Method.java:491)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-19 15:45:58.010: ERROR/AndroidRuntime(3186):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
