Help with AlertDialog in Android
<p>The application seems to crash when I try and get the text from the EditText:</p>

<pre><code>package com.example.helloandroid;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.util.Log;

import android.app.Activity;
import android.os.Bundle;

public class MatrixMultiply extends Activity implements OnClickListener {
/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    View newButton = findViewById(R.id.new_button);
    newButton.setOnClickListener(this);
    View aboutButton = findViewById(R.id.about_button);
    aboutButton.setOnClickListener(this);
    View exitButton = findViewById(R.id.exit_button);
    exitButton.setOnClickListener(this);
}
public void onClick(View v) { 
    switch (v.getId()) { 
    case R.id.about_button:
        Intent i = new Intent(this, About.class);
        startActivity(i);
        break;
    case R.id.new_button:
        openNewGameDialog();
        break;
    case R.id.exit_button:
        finish();
        break;
// More buttons go here (if any) ...
}
}
private static final String TAG = "Matrix";

private void openNewGameDialog() {

     LayoutInflater factory = LayoutInflater.from(this);            
        final View textEntryView = factory.inflate(R.layout.text, null);

        AlertDialog.Builder alert = new AlertDialog.Builder(this); 

        alert.setTitle("Matrices"); 
        alert.setMessage("Please enter the size of the matrix"); 
        // Set an EditText view to get user input  
        alert.setView(textEntryView); 
        AlertDialog matrixSize = alert.create();

        final EditText height1 = (EditText) matrixSize.findViewById(R.id.h1);
        final EditText width1 = (EditText) MatrixMultiply.this.findViewById(R.id.w1);
        final EditText height2 = (EditText) MatrixMultiply.this.findViewById(R.id.h2);
        final EditText width2 = (EditText) MatrixMultiply.this.findViewById(R.id.w2);


        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 

            String h1 = height1.getText().toString();
            String w1 = width1.getText().toString();
            String h2 = height2.getText().toString();
            String w2 = width2.getText().toString();


        } 
        }); 

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int whichButton) { 
            // Canceled. 
          } 
        }); 

        alert.show(); 
}


private void startGame(int i) { Log.d(TAG, "clicked on " + i); // Start game here...
}
}
</code></pre>
