Complete the code to create a new Android Activity class named MainActivity.
class MainActivity : [1]() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }
The MainActivity class should extend AppCompatActivity to work properly as an Android activity.
Complete the code to set the layout resource for the activity in onCreate.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
[1](R.layout.activity_main)
}The method setContentView sets the UI layout for the activity.
Fix the error in the import statement to use the correct Android package for Bundle.
import [1].os.Bundle
The correct package for Bundle is android.os.Bundle.
Fill both blanks to declare a new Android project package and main activity class header.
package [1] class MainActivity : [2]()
The package name should be your app's unique identifier like com.example.myapp. The activity class should extend AppCompatActivity.
Fill all three blanks to complete the minimal MainActivity code with onCreate method and layout setting.
package [1] import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : [2]() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) [3](R.layout.activity_main) } }
The package name is usually your app's domain reversed like com.example.app. The activity extends AppCompatActivity. The layout is set with setContentView.