...

/

Activity Declaration and Keyboard Support

Activity Declaration and Keyboard Support

This lesson will cover how to declare activity and refine user interface for better keyboard support.

Activity declaration #

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

Press + to interact
public class LoginActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
}

Android Studio IDE automatically adds @Nullable or @NonNull annotations for overridden methods. These annotations indicate whether parameter or return value can be null or not.

All activities must be registered in AndroidManifest.xml, and because we want LoginActivity to be launched by ...