How to add subtitle to spinner in the action bar

☆樱花仙子☆ 提交于 2019-12-06 05:22:46

We can achieve this functionality in different way.

custom_toolbar.xml

<android.support.v7.widget.Toolbar>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
             .... For Title
        />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <TextView
              ....//For Select things...
            />

            <ImageView
                .... down arrow image
            />
        </LinearLayout>
    </LinearLayout>
</android.support.v7.widget.Toolbar>

For add in mainlayout.xml

 <include
   android:id="@+id/toolbar"
   layout="@layout/custom_toolbar" />

In Activity

 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   if (toolbar != null) {
       setSupportActionBar(toolbar);
   }

And getClick event of textView and Open AlertDialog with setSingleChoiceItems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!