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 trialDemetre Tsagouris
8,517 PointsThe question must be broken. The challenge can't resolve "setTextColor" method.
I am trying to set the text color to Blue but I keep getting an error that the "setTextColor" method can't be resolved. I tried the same method for a text view in android studio and it worked. So my best guess id that the challenge is broken.
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)
}
}
1 Answer
Seth Kroger
56,414 PointsAs I recall, you need to use property assignment here (see the line above it as a template/hint) instead of a setter.