Which tasks can be performed in onCreate()?

Master Kotlin and Android with our engaging quizzes. Test your knowledge with multiple choice questions and detailed explanations. Prepare thoroughly for your Android development journey!

The correct choice is that configuring views, such as setting the layout manager for a recycler view, is a task that can be performed in onCreate(). This method is part of the activity lifecycle in Android and is called when the activity is first created. It is the ideal place to perform one-time initialization such as setting up the user interface and linking any visual components to data sources.

In onCreate(), you typically set the layout for the activity using setContentView(), which allows you to reference the layout's views. After this, configuring views is essential for setting up how they will behave. For example, setting the layout manager of a recycler view is crucial to define how items in the recycler view are laid out. This preparation ensures that when the activity is running, it can properly handle user interactions and display data correctly.

The other tasks mentioned in the choices, like determining the items for the options menu or setting onClickListeners for those items, are not performed within the onCreate() method. The options menu is generally set up in the onCreateOptionsMenu() method, and the listeners for UI elements are usually set after the views have been initialized, but can occur later in the activity lifecycle or in response to specific events. Retrieving extras from

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy