I'm trying to learn how to develop for Android and got a book which
has some exercises. One of them asks to use the get.Resources().... to
change text color. When I use get.Resources... the emulator crashes
with the following msg:
"The application Droid #1(process com.androidbook.droid1) has stopped
unexpectedly. Please try again"
Here's my code:
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="bgColor">#006400</color>
<color name="appTextColor">#00ff00</color>
</resources>
---------------------
DroidActivity.java
package com.androidbook.droid1;
import android.app.Activity;
import android.os.Bundle;
public class DroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
int textColor = getResources().getColor(R.color.appTextColor);
NOW... if comment the int textColor line and add this
android:textColor="@color/appTextColor"
to my main.xml file, it works ok.
Any help will be greatly appreciated.
Thanks.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en