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 Build a Simple Android App (2014) Testing and Debugging Toast Notifications

if I run the app in my phone the app stop working when I click the button should I be worry about it ??

please let me know

4 Answers

Got it ...

Have a look at this line in your onClickListener:


Here you're trying to change the colour of the text but haven't called the right method. You need .setTextColor like:


That should work fine.


Thanks steve that was helpful

What error are you getting? Does it just stop with a warning?

In Android Studio, does anything appear at the botom of the screen in the "Logcat" area? If so, post a copy of those messeages as that will help us work out what is going on.

Also, post your code too - we can see if there's an issue there.

I don't have any error in my Android studio, but the app dose not work as it should be !! only in my phone !!

Hi Ahmed,

So in the emulator your code works fine but on your phone it stops working?

If you're running the app via Studio and sending the run task to your phone, any error should appear in Logcat - does it not?

What happens on your phone? Does it give some warning like "Unfortunately, your app has stopped working" or does it just not work?

Again, show us your code! We can take that from there.

Let us know the above stuff and we can go from there.


public class FactsActivity extends ActionBarActivity {

    private FactBook mFactBook = new FactBook();
    private ColorWheel mColorWheel = new ColorWheel();
    protected void onCreate(Bundle savedInstanceState) {

        // declare our view variables and assign the view from the layout file
        final TextView factLabel = (TextView) findViewById(R.id.FactTextView);
        final Button showFactButton = (Button) findViewById(R.id.showFactButton);
        final RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout);

        View.OnClickListener listener = new View.OnClickListener() {
            public void onClick(View view) {
                String fact = mFactBook.getFact();
                // update the label with our dynamic fact

                int color = mColorWheel.getColor();

and yes it show a warning in phone then will close the app...!

public class ColorWheel{

    // Member variable (properties about the object)
         public String[] mColors = {
            "#39add1", // light blue
            "#3079ab", // dark blue
            "#c25975", // mauve
            "#e15258", // red
            "#f9845b", // orange
            "#838cc7", // lavender
            "#7d669e", // purple
            "#53bbb4", // aqua
            "#51b46d", // green
            "#e0ab18", // mustard
            "#637a91", // dark gray
            "#f092b0", // pink
            "#b7c0c7"  // light gray

        // Method (abilities : things the object can do)
        public int getColor(){

        // The button was clicked, so update the fact label with a new fact
        String color = "";
        // Randomly select a fact
        Random randomGenerator = new Random(); // Construct a new Random number generator
        int randomNumber = randomGenerator.nextInt(mColors.length);

        color = mColors[randomNumber];
            int colorAsInt = Color.parseColor(color);

        return colorAsInt;
public class FactBook {

    // Member variable (properties about the object)

    // Method (abilities : things the object can do)
         public String[] mFacts = {
                "Ants stretch when they wake up in the morning.",
                "Ostriches can run faster than horses.",
                "Olympic gold medals are actually made mostly of silver.",
                "You are born with 300 bones; by the time you are an adult you will have 206.",
                "It takes about 8 minutes for light from the Sun to reach Earth.",
                "Some bamboo plants can grow almost a meter in just one day.",
                "The state of Florida is bigger than England.",
                "Some penguins can leap 2-3 meters out of the water.",
                "On average, it takes 66 days to form a new habit.",
                "Mammoths still walked the earth when the Great Pyramid was being built." };

             public String getFact() {

        // The button was clicked, so update the fact label with a new fact
        String fact = "";
        // Randomly select a fact
        Random randomGenerator = new Random(); // Construct a new Random number generator
        int randomNumber = randomGenerator.nextInt(mFacts.length);

        fact = mFacts[randomNumber];

        return fact;

these all 3 classes that I have done so far >>!!

and these are the errors that I got when I run the app

02-21 17:50:55.652 8201-8201/alghafli.facts E/AndroidRuntimeοΉ• FATAL EXCEPTION: main Process: alghafli.facts, PID: 8201 android.content.res.Resources$NotFoundException: String resource ID #0xff53bbb4 at android.content.res.Resources.getText(Resources.java:1403) at android.widget.TextView.setText(TextView.java:5129) at alghafli.facts.FactsActivity$1.onClick(FactsActivity.java:41) at android.view.View.performClick(View.java:4754) at android.view.View$PerformClick.run(View.java:19605) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5748) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at dalvik.system.NativeStart.main(Native Method)

Great - that's what we needed. In your Logcat, the error is saying: "NotFoundException: String resource ID #0xff53bbb4"

That's one of your colours that's not working. So, I suspect that none of your colours work as I see no reason why that one should fail in isolation.

I've just pulled your code into my environment and am getting the same problem. So, the way the colours are being used in ColorWheel is causing a problem ... I shall investigate!