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 Android Data Persistence Introduction to Data Persistence Using EditText Data

Zubeyr Aciksari
Zubeyr Aciksari
21,074 Points

We have accessed the actual controls, but lets now set the TextView's contents with whatever is in the EditText.

Can someone please send the answer? I am really stuck here.. Thanks!

CodeChallenge.java
EditText entryField = (EditText)findViewById(R.id.entry_field);
TextView textHolder = (TextView)findViewById(R.id.text_holder);
textView.setText(editText.getText()).toString();

3 Answers

Harry James
Harry James
14,780 Points

Hey Zubeyr!

First of all, we should reference the EditText and TextView via their variables on the Code Challenge (Rather than using EditText.< code >, use entryField.< code >) otherwise, Java doesn't know what we're referring to by EditText as, there's no such variable!

After that, be sure to check your code here:

(editText.getText()).toString();
                  ^           ^

You seem to have got your brackets mixed up a bit. Just remember that each method call has two brackets after it (()) and you should be able to see where you've gone wrong.


Hopefully this should help you out but, if you have any more problems, give me a shout and I'll be happy to help :)

Zubeyr Aciksari
Zubeyr Aciksari
21,074 Points

wow, this was so easy, just missed out on one simple detail that i figured out thanks to you.. Thanks a lot!

Hi Zubeyr,

EditText entryField = (EditText)findViewById(R.id.entry_field);
TextView textHolder = (TextView)findViewById(R.id.text_holder);
//textView.setText(editText.getText()).toString(); //This is wrong.

You're accessing textView and editText and they don't exist, instead you should use the instances of EditText and TextView that you created. Hint:

textHolder.setText( [get the String of entryField here] );

Hope this helps :)