kotlin & Java: How to hide the toolbar only for specific fragments

Introduction

Since it is expected that we will continue to encounter implementations that do not display the toolbar only for specific fragments in Android development, we will summarize it below including a memorandum.

For kotlin

kotlin


//I want to hide
(activity as AppCompatActivity?)!!.getSupportActionBar()!!.hide()

//I want to display
(activity as AppCompatActivity?)!!.getSupportActionBar()!!.show()

For Java

Java


//I want to hide
((AppCompatActivity)getActivity()).getSupportActionBar().hide();

//I want to display
((AppCompatActivity)getActivity()).getSupportActionBar().show();

That is all.

This is the article I referred to this time. Please refer to it for more details. (Java.) https://stackoverflow.com/questions/29128162/android-hide-toolbar-in-specific-fragment

We hope for your reference.

Recommended Posts

kotlin & Java: How to hide the toolbar only for specific fragments
[Java] (for MacOS) How to set the classpath
How to study kotlin for the first time ~ Part 2 ~
How to study kotlin for the first time ~ Part 1 ~
How to check for the contents of a java fixed-length string
[Java] How to use the HashMap class
About the procedure for java to work
[Java] How to use the toString () method
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
[Java] How to set the Date time to 00:00:00
[Java] How to get the current directory
[Processing × Java] How to use the class
How to install the legacy version [Java]
How to get the date in java
[Processing × Java] How to use the function
Memo for migration from java to kotlin
[Java] How to get to the front of a specific string using the String class
[Java] How to test for null with JUnit
[Java] Add quotes only to specific CSV columns
[Java] How to use Thread.sleep to pause the program
Initial settings for rewriting Java projects to Kotlin
How to hide null fields in response in Java
[Java] How to get random numbers excluding specific numbers
How to use the replace () method (Java Silver)
[Java] How to get the redirected final URL
[Java] Memo on how to write the source
[Java] How to get the authority of the folder
How to write Java String # getBytes in Kotlin?
[Java] How to make multiple for loops single
[Java] How to omit the private constructor in Lombok
How to write Scala from the perspective of Java
[Java] How to extract the file name from the path
[Java] How to get the maximum value of HashMap
[Android Studio] [Java] How to fix the screen vertically
How to use Truth (assertion library for Java / Android)
[Java] How to erase a specific character from a character string
How to loop Java Map (for Each / extended for statement)
What Java engineers need to prepare for the Java 11 release
How to execute WebCamCapture sample of NyARToolkit for Java
How to get the class name / method name running in Java
How to use SAS tokens for Azure Event hubs (Java)
SDWebImage: How to clear the cache for a particular UIImageView
How to use trained model of tensorflow2.0 with Kotlin / Java
[Must-see for apprentice java engineer] How to use Stream API
I tried to summarize the basics of kotlin and java
Difference between Java and JavaScript (how to find the average)
How to run only specific files with gem's rake test
Refer to C ++ in the Android Studio module (Java / kotlin)
Uppercase only the specified range with substring. (How to use substring)
How to deploy a kotlin (java) app on AWS fargate
How to derive the last day of the month in Java
How to switch Java in the OpenJDK era on Mac
A memorandum to reach the itchy place for Java Gold
For Java beginners: List, Map, Iterator / Array ... How to convert?
Reintroduction to Java for Humanities 0: Understanding the Act of Programming
Investigated how to call services with Watson SDK for Java
How to play MIDI files using the Java Sound API
[Java] How to use Map
How to lower java version
[Java] How to use Map