Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App with Java Basic Android Programming Accessing Views in Code: Declaring Variables

my funFactsActivity did not look like the screen and I could not declare the variables even though I imported everything

my funActivity looked like this:

package com.weebly.httpscollegepeerhelp.funfacts

import android.support.v7.app.AppCompatActivity
import android.os.Bundle


class FunFactsMainActivity  :  AppCompatActivity() {


    protected override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_fun_facts_main)
    }
}

when I delete everything and put in what he has it still shows error.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

This looks like Kotlin code, not Java. It seems like you've created the project )or just that file) using Kotlin. Try creating a new project and make sure you don't click or mark any Kotlin-related features.

So does the other 2 files under the folder java have to be in java too? ExampleUnitTest and ExampleInstrumentedTest

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

Yes, everything should be .java instead of .kt here. This whole course is based on Java. There are other Treehouse courses that use Kotlin for Android development.