android - How to make the Toolbar title clickable exactly like on ActionBar, without setting it as ActionBar? -



android - How to make the Toolbar title clickable exactly like on ActionBar, without setting it as ActionBar? -

background

i wish show actionbar on preferenceactivity, it's not available pre-honeycomb devices (even in back upwards library).

because such class isn't available on back upwards library, can't phone call "setsupportactionbar" . don't wish utilize library (like this one) since of libraries i've found still utilize holo style, didn't updated far, in mind.

to this, i'm trying mimic look&feel of title of actionbar new toolbar class, presented on back upwards library v7 .

the problem

i've succeeded putting title , "up" button, can't find out how create them clickable normal action bar, including effect of touching.

the code

here's code:

settingsactivity.java

public class settingsactivity extends preferenceactivity { @override protected void oncreate(final bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_settings); addpreferencesfromresource(r.xml.pref_general); final toolbar toolbar=(toolbar)findviewbyid(r.id.toolbar); toolbar.setbackgroundcolor(getresources().getcolor(r.color.windowbackgroundcolor)); toolbar.settitle("settings"); toolbar.setclickable(true); toolbar.setlogo(getresidfromattribute(this,r.attr.homeasupindicator)); } public static int getresidfromattribute(final activity activity,final int attr) { if(attr==0) homecoming 0; final typedvalue typedvalueattr=new typedvalue(); activity.gettheme().resolveattribute(attr,typedvalueattr,true); homecoming typedvalueattr.resourceid; } }

activity_settings.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.antonioleiva.materialeverywhere.settingsactivity" > <include android:id="@+id/toolbar" layout="@layout/toolbar" /> <framelayout android:layout_width="match_parent" android:layout_height="match_parent" > <view android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/abs__ab_solid_shadow_holo" /> <listview android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" /> </framelayout> </linearlayout> what i've tried

i've tried of click listeners types of toolbar class, none helped.

the thing worked utilize "setnavigationicon" instead of "setlogo", makes title&icon beingness clicakable, yet icon shows effect of beingness clicked (even if click on title).

the question

how can add together & sense of toolbar, have title & logo of actionbar?

just remember toolbar viewgroup can add together textview , hear onclick events that.

add textview toolbar in xml:

<android.support.v7.widget.toolbar android:id="@+id/toolbar_top" android:layout_height="wrap_content" android:layout_width="match_parent" android:minheight="?attr/actionbarsize" android:background="@color/action_bar_bkgnd" app:theme="@style/toolbartheme" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="settings" android:id="@+id/toolbar_title" /> </android.support.v7.widget.toolbar>

listen clicks in activity:

toolbartop.findviewbyid(r.id.toolbar_title).setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { log.d(tag,"clicked"); } });

android android-actionbar-compat android-toolbar

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -