setSupportActionBar (androidx.appcompat.widget.Toolbar) in AppCompatActivity cannot be applied

前端 未结 8 1488
半阙折子戏
半阙折子戏 2020-12-07 05:36

An error showing incompatible types Android widget toolbar cannot be converted in Java compiler while working on Android Studio.

    Toolbar toolbar = (Toolb         


        
8条回答
  •  清歌不尽
    2020-12-07 06:11

    Try to replace this:

    import android.widget.Toolbar;
    

    With this:

    import androidx.appcompat.widget.Toolbar;
    

    By the way, if you are using androidx. Run it's migration process. The android support libraries will not be supported in the future. You can read about it here:

    AndroidX Migrating to AndroidX

提交回复
热议问题