...

/

Activity Declaration and Keyboard Support

Activity Declaration and Keyboard Support

Discover how you can declare activity and refine the user interface for better keyboard support in this lesson.

Activity declaration

In the previous lesson, we created the activity_login.xml layout. Now it’s time to create the LoginActivity class and bind our layout to this activity by using the setContentView method.

Press + to interact
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
}
}

All activities must be registered in AndroidManifest.xml, and because we want LoginActivity to be launched by default when the application starts, it must be declared with the MAIN and LAUNCHER intent filters. So, let’s move the intent filters from the MainActivity to the ...