Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Stage 2 --- Error Messages with Dialogs

Hi , i have a question about the code challenge 2/5. The objective is to set the mUserInput using the text value from mNumberField.

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 = (EditText)findViewbyId(R.id.****);
    // Check to see if the user's number is correct
    boolean isCorrect = GuessEngine.testGuess(mUserInput);



What should i put in the findViewById or this is not the way to set it? Thanks.

1 Answer

Daniel Hartin
Daniel Hartin
18,106 Points

It is a bit unclear but the description states that the view is declared in the onCreate method. What you should type is mUserInput = mNumberField. getText().toString();

This assigns the user input the numberfield value by using the getText method, you also need to add toString at the end to convert the value to a string to match the variable type.