Contextual Action Mode – Android Studio Tutorial
In this video we will learn, how to activate the contextual action mode, which is very similar to the floating context menu, but shows the menu options in the action bar instead of a pop up menu. We will activate this contextual action menu on a long click, by setting an onLongClickListener on our View. We will set it’s title and implement an ActionMode.Callback interface, in which we then override the oncreateActionMode, onPrepareActionMode, onActionItemClicked and onDestroyActionMode methods. There we inflate our app bar menu with our own menu xml file and handle click events on the single menu items.
Lastly we will learn, how to change the color of our action mode app bar and how to prevent it from pushing our toolbar away, instead of displaying on top of it, by using the windowActionBarOverlay attribute in our styles.xml file.
Source code:
https://gist.github.com/codinginflow/c4b4f381460488ad941855120da1d85e
____________________
💻 Find the BEST programming tutorials on TutHub:
https://tuthub.io
⭐ Get my MVVM Caching Course now:
https://codinginflow.com/caching
❗ Subscribe to the channel:
https://www.youtube.com/c/codinginflo…
📨 Subscribe to the Coding in Flow newsletter:
https://codinginflow.com/newsletter
❓ Join our free developer community:
https://discord.gg/TSnMvmc
📣 Follow Coding in Flow on other sites:
Facebook: https://www.facebook.com/codinginflow
Instagram: https://www.instagram.com/codinginflow
TikTok: https://www.tiktok.com/@codinginflow
Twitter: https://twitter.com/codinginflow
Github: https://github.com/codinginflow
💰 Business requests, sponsoring, etc.: info@codinginflow.com
Views :29433
android studio