简体   繁体   中英

Class BadgeDrawable not found. How to use material design BadgeDrawable in Android

For the first time, I am trying to use the badge notification icon on the material TabItem. My goal is to show the badge with the total number of items in the RecyclerView. I was going through with this document Tab Layout - Material Components for Android and trying to implement the functionality accordingly, but at this line BadgeDrawable badge = tablayout.getTab(0).getOrCreateBadge(); I am getting error that BadgeDrawable class not found.

Can anyone help me with this?

Thanks

The BadgeDrawble integration into TabLayout was released with the 1.1.0-alpha07 .

Use the latest 1.1.0 version available today:

implementation 'com.google.android.material:material:1.1.0'

Resolved by upgrading com.google.android.material:material version from 1.0.0 to 1.1.0-alpha10 in build.gradle(Module:app) file.

dependencies {
implementation 'com.google.android.material:material:1.1.0-alpha10'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM