Problems with Challenge 1


I’m having problems with challenge 1. I tried copying the same thing I did to make the listener for the nextButton. What I ended up with was this.

mQuestionTextView = (TextView)findViewById(; mQuestionTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length; updateQuestion(); } });

This seemed like it should work but on the emulator and on my actual device (Nexus 5), the TextView didn’t seem to respond to clicking. I searched around in the forums here and saw that someone else had added a line of code to the activity_quiz.xml to make the TextView clickable. This is what my file looks like now.


<TextView android:id="@+id/question_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="24dp" android:clickable="true"/>

Even with this, the TextView doesn’t seem to respond to clicking. I’m stumped.


Have you tried double clicking the TextView? If that fixes your problem, try adding the attribute android:focusable=“false” to the textview


I tried switching over to Eclipse (was using Android Studio before) and copied over my code. It worked fine in Eclipse. I’m not exactly sure what was wrong but it works now. Additionally I tested with and without the “clickable” code on the textView. It turns out it did not need this code.


My guess is you ran into the same problem I am. I’m also using Android Studio, and I’m pretty sure the problem is related to how we duplicated the project for making our challenge version. I think it’s still launching the old packaged app. As an experiment, try to make some obvious visual changes and see if it changes anything.

I haven’t figured out how to solve it yet, but it seems like creating a new project and copying in the source files would be an obvious (though less than ideal) solution.


Okay, if you ran into the same problem I did, try duplicating your projects by copying the project folder first (via your OS) and then using the Import command in Android Studio to open it (as opposed to opening the project). I think that’s fixing some source path issues or something. It works for me now.


My solution was the same as the one posted with one exception. Instead of duplicating the line

mCurrentIndex = (mCurrentIndex +1) % mQuestionBank.length;

I added it to the updateQuestion() method.


Man… It took me around half an hour to figure out what the heck I was doing wrong. I had typed the exact code (on my own) that rodrequezr36 had typed. But it wasn’t working. I tried all the suggestions in this thread. I thought maybe when I made the Copy of the project, something went wrong, so I deleted the copy project to start over. Then I realized what went wrong. When you make the copy of the project, all the source code windows from the original project stay open. So I was editing the files of the original project and right clicking on the copy project to run it.

&%#@$! :open_mouth:

So I just backed out all the changes from after what I originally typed, ran it from the original project, and it worked!



In activity_quiz.xml under <TextView type


This will make the TextView red. Turns out I had the right code all along but I was pressing on the wrong place.