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 trialEnyang Mercy
Courses Plus Student 2,339 PointsAndroid - adding more colors kotlin
Help!!!!!!!!! compilation gone wrong What is wrong here?
import android.app.Activity
import android.os.Bundle
import android.widget.TextView
import android.widget.RelativeLayout
class MealActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_meal)
val foodLabel = findViewById(R.id.foodTextView) as TextView
val drinkLabel = findViewById(R.id.drinkTextView) as TextView
val mealLayout = findViewById(R.id.mealLayout) as RelativeLayout
mealLayout.backgroundColor = Color.RED
foodLabel.settextColor = Color.BLUE
drinkLabel.settextColor = Color.GRAY
}
}
1 Answer
Jebadeiah Jones
10,429 PointsThe syntax we're to use is actually
foodLabel.textColor = Color.BLUE
drinkLabel.textColor = Color.GRAY
I don't know where in the lesson it says that, but this was answered elsewhere and that was what worked.
Jebadeiah Jones
10,429 PointsJebadeiah Jones
10,429 PointsMake sure to capitalize 'Text' when using 'setTextColor'. That being said, it still doesn't work. I am flummoxed as well. I've tried what you've got and I was sure it was right. I tried using foodTextView in lieu of foodLabel. I tried using setTextColor(Color.BLUE) instead. I've tried all sorts of wrong answers, but I am absolutely sure the right one is
But it says it's wrong! I'm confused.