Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Adding Users Using Parse.com Error Messages with Dialogs

Drashti Bhatt
Drashti Bhatt
1,860 Points

how to solve this?

how to solve this?

GuessNumberActivity.java
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.widget.EditText;

public class GuessNumberActivity extends Activity {

    protected String mUserInput;
  protected EditText mNumberField;

    /*
     * onCreate() and other code has been omitted for brevity!
     */

    public void makeGuess() {
        // Set mUserInput here!    
       mUserInput = mNumberField.getText()+"";

        // Check to see if the user's number is correct
        boolean isCorrect = GuessEngine.testGuess(mUserInput);

    }
}

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

For part 3 of the challenge use the AlertDialog.Builder constructor create a new instance of AlertDialog.Builder and assign it to the variable builder:

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.widget.EditText;

public class GuessNumberActivity extends Activity {

    protected String mUserInput;
    protected EditText mNumberField;

    /*
     * onCreate() and other code has been omitted for brevity!
     */

    public void makeGuess() {
        // Set mUserInput here!        
       mUserInput = mNumberField.getText()+"";

        // Check to see if the user's number is correct
        boolean isCorrect = GuessEngine.testGuess(mUserInput);

      if (isCorrect) {
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
      }

    }
}