Android 如何在“活动”使用onUserInteraction()时获取工具栏项上的onClick事件

Android 如何在“活动”使用onUserInteraction()时获取工具栏项上的onClick事件,android,android-toolbar,Android,Android Toolbar,当“活动”使用OnUserInteraction()方法时,是否可以在工具栏的项目上获取onClick()事件?工具栏基本上只是一个视图组,因此我们可以向其添加文本视图并侦听类似的onClick事件 例如,您有一个XML文本视图工具栏,如下所示: <android.support.v7.widget.Toolbar android:id="@+id/tb" android:layout_height="wrap_content" android:layout_width="match_pa

当“活动”使用OnUserInteraction()方法时,是否可以在工具栏的项目上获取onClick()事件?

工具栏基本上只是一个视图组,因此我们可以向其添加文本视图并侦听类似的onClick事件

例如,您有一个XML文本视图工具栏,如下所示:

<android.support.v7.widget.Toolbar
android:id="@+id/tb"
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/tb_title" />

</android.support.v7.widget.Toolbar>

嗨,米蒂什,谢谢你的快速回复。但当activity重写onUserInteraction()方法时,所有的点击和触摸事件都会被它消耗掉。
tb.findViewById(R.id.toolbar_title).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    }
});
enter code here