Remove the title text from the action bar in one single activity

前端 未结 4 575
囚心锁ツ
囚心锁ツ 2020-12-18 12:14

I added an action bar with a dropdown menu to my activity but it also shows the application name.

Each of my activities has an action bar and each of them use the th

4条回答
  •  一整个雨季
    2020-12-18 13:04

    For this kind of simple stuff you just have to go to the source to find the answer: here the full explanation: http://developer.android.com/guide/topics/ui/actionbar.html#Dropdown

    and here some guide code, to include the spinner on the action bar:

     ActionBar actionBar = getActionBar();
     actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    

    after that is just put a listener for the changes and setting the a spinner adapter.

    and you can use:

     setTitle("");
    

    to remove the title. I've been checking on my codes here, you can also give a try on:

     requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    It should just remove the title, and leave the title bar. Remember that you must call this before setContentView

    happy coding.

提交回复
热议问题