0
I have the code below, which calls a Fragment, in Activity Schedulesearch:
@Override
public void openFragment(int home, boolean search, boolean changeClickDirection) {
if (home == 0) {
PlaceListScheduleFragment fragment = new PlaceListScheduleFragment();
Bundle bundle = new Bundle();
bundle.putInt("home_type", 0);
bundle.putBoolean("search", true);
bundle.putBoolean("CHANGE_DIRECTION", changeClickDirection);
fragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction()
.add(R.id.containerLinear, fragment)
.addToBackStack("PlaceListScheduleFragment")
.commit();
getSupportFragmentManager().executePendingTransactions();
} else {
PlaceListScheduleFragment fragment = new PlaceListScheduleFragment();
Bundle bundle = new Bundle();
bundle.putInt("home_type", 1);
bundle.putBoolean("search", true);
bundle.putBoolean("CHANGE_DIRECTION", changeClickDirection);
fragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction()
.add(R.id.containerLinear, fragment)
.addToBackStack("PlaceListScheduleFragment")
.commit();
getSupportFragmentManager().executePendingTransactions();
}
}
It has a Toolbar implemented, but I can’t make it go a title to the open Fragment, how to do this?
EDIT:
XML Activity:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/containerSearch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:fitsSystemWindows="true"
android:gravity="center_horizontal"
tools:context="com.holandago.schedule.views.ScheduleSearchActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar_Search_ask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/azul_bynd"
android:gravity="center"
app:titleTextColor="@color/button_text_color">
<TextView
android:id="@+id/txtToolBarTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TITULO"
android:textColor="@color/button_text_color"
android:textSize="20dp"
android:visibility="visible"
android:textStyle="bold" />
</android.support.v7.widget.Toolbar>
....
<LinearLayout
android:id="@+id/containerLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:orientation="vertical">
</LinearLayout>
XML Fragment:
<LinearLayout
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/azul_bynd"
android:orientation="vertical">
</LinearLayout>
<SearchView
android:id="@+id/query_schedule"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="1dp"
android:queryHint="@string/search_hint"
android:textColor="@android:color/black"
android:background="@drawable/border_search_address"
android:elevation="12dp"/>
<ListView
android:id="@+id/listViewSchedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp" />
<!--<TextView-->
<!--android:id="@android:id/empty"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:gravity="center"-->
<!--android:layout_below="@+id/query_schedule"-->
<!--android:layout_alignParentStart="true"-->
<!--android:layout_marginTop="30dp" />-->
It doesn’t work that way, I had already tried. I have a Toolbar with a textview to receive the text, and it doesn’t go to Fragment.
– Henrique