An error showing incompatible types Android widget toolbar cannot be converted in Java compiler while working on Android Studio.
Toolbar toolbar = (Toolb
You can invoke ActivityCompat#requireViewById which allows to omit the type cast and returns a @NonNull
Toolbar
reference:
Toolbar toolbar = ActivityCompat.requireViewById(this, R.id.toolbar);
setSupportActionBar(toolbar);
The title can be set on the @Nullable
ActionBar
reference returned by AppCompatActivity#getSupportActionBar:
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("GPS PRESENCE SYSTEM");
}
You are using androidx and Android both at the same time. That is throwing an error. Either use androidx or use android appcompat.