У меня есть ящик для навигации с пользовательской панелью инструментов. Я пытаюсь получить доступ к textView на панели инструментов в Fragment и установить текст в фрагменте. Возможно ли это, если да, то как?Доступ к текстовому представлению панели инструментов из фрагмента в android
Вот toolbar.xml у меня есть:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:id="@+id/toolbar"
style="@style/ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/backgroundcolor"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/relativeLayoutID">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_centerVertical="true"
android:text="@string/register_title"
android:textColor="@color/blackText"
android:textSize="@dimen/text_size_medium" />
<ImageView
android:id="@+id/action_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="right|center"
android:contentDescription="@string/logo"
android:paddingRight="5dp"
android:src="@drawable/logoactionbar" />
</RelativeLayout>
Я хочу, чтобы установить текст toolbar_title в соответствии с fargment я щелкнул. Как получить доступ к ним во Фрагменте.
Дайте мне знать!
Спасибо!
Куда вы включили панель инструментов? Оттуда вы можете найти его в действии или фрагменте – Harry
@ Харри: Можете ли вы привести пример? – TheDevMan