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 trialJay Reyes
Python Web Development Techdegree Student 15,937 PointsHow do I change the string without hardcoding it?
It turns out we have a Values folder in the project tree. This folder contains strings.xml Inside strings.xml, you can create a string element that contains our beloved string "Did You Know?" I decided to name it as main_page_text.
<string name="main_page_text">Did You Know?</string>
Then in activity_fun_facts.xml, I changed the value of android:text
:
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/main_page_text" />
Voila, now I can change the string in one place instead of multiple times in multiple places.