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 Styles and Themes in Android Using Styles in Layouts Styling EditTexts and Buttons

shahaf cohen
shahaf cohen
1,896 Points

Bummer! Oops! Don't include 'android:hint' in the style.

what is the problem here???

styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
  <style name="CustomEditText"> 
    <item name="android:layout_width">match_parent</item>   
    <item name="android:layout_height">wrap_content</item>
    <item name="android:hint">@string/hint_name</item>
    <item name="android:textSize">20sp</item>
    <item name="android:textColor">@color/dark_green</item>
    <item name="android:layout_alignParentLeft">true</item>
  </style>
</resources>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <EditText
        android:id="@+id/nameField"
        style="@style/CustomEditText"
        android:layout_alignParentTop="true"/>

    <EditText
        android:id="@+id/cityField"
        android:layout_below="@id/nameField"
        style="@style/CustomEditText"/>

</RelativeLayout>

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The problem here is that you were only supposed to move things that have the same value to the <style>. The hints in the beginning did not have the same value.

The hint under the nameField was:

android:hint="@string/hint_name"

And the hint under the cityField was:

android:hint="@string/hint_city"

As you can see, the values weren't the same so they should not have been moved to the styles.xml. Try removing that part from the styles.xml and then put back these properties in the activity_main.xml.

Hope this helps! :sparkles:

shahaf cohen
shahaf cohen
1,896 Points

WoW! Just saved me twice!!! Thanks!! :-)