First, let's add a color for error messages... Add this line to your colors.xml:
<color name="error">#cc3333</color>Next, let's add a string for the error message... Add this line to strings.xml:
Now, let's create a new src/main/android/res/values/styles.xml:<string name="errmsg">ERROR!</string>
<?xml version="1.0" encoding="utf-8"?>In your main.xml, change this line:
<resources>
<style name="DefaultText">
<item name="android:textColor">@color/black</item>
</style>
<style name="ErrorText">
<item name="android:textColor">@color/error</item>
<item name="android:textStyle">bold|italic</item>
</style>
</resources>
to:android:textColor="@color/black"
style="@style/DefaultText"
Now to link in a 2nd text example so we can see them together... Make a copy of the TextView inside the LinearLayout and change these two lines:
to:android:text="@string/hello"
style="@style/DefaultText"
android:text="@string/errmsg"
style="@style/ErrorText"
Redeploy (mvn clean install) and you can now see the previous black-on-cornsilk "Hello World!" as well as a bold-italic-red "ERROR!".
No comments:
Post a Comment