Hide Title bar in Android

A simple but useful code snippet to hide title bar in Android. The code snippet is


The important thing is, you need to put this code in onCreate() of the activity class. That also before setContentView(). If we put the requestWindowFeature() after setContentView() then we will get an exception. The exception will look like,

E/AndroidRuntime(  277): FATAL EXCEPTION: main
E/AndroidRuntime(  277): java.lang.RuntimeException: Unable to start activity ComponentInfo 
android.util.AndroidRuntimeException: requestFeature() must be called before adding content

So the code will be like,
public void onCreate(Bundle savedInstanceState) {

Popular posts from this blog

Open Gallery and get the selected image in appplication

Dismiss or Cancel dialog by swipe gesture

AlarmManager and Notification in Android