I set my custom toolbar and set "setHomeButtonEnabled" and "setDisplayHomeAsUpEnabled" to true and for some odd reason the toolbar is showing but not the actual back button. I've tried setting a custom icon and setting the toolbar onclick when the fragment is being changed and the toolbar always shows but the backarrow never shows. Is it possibly because my registeractivity is not being called?
public class RegisterActivity extends BaseActivity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_register);
ButterKnife.bind(this);
Toolbar toolbar = findViewById(R.id.my_toolbar);
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
the activity where the fragments go
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/ghostWhiteColor"
android:fitsSystemWindows="true"
tools:context="com.vice.de.flu.activity.RegisterActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/holo_blue_light"/>
</android.support.design.widget.AppBarLayout>
<!--wizard>-->
<FrameLayout
android:id="@+id/fragment_register"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>
my manifest
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.RegisterActivity"
android:windowSoftInputMode="adjustPan|adjustResize">
</activity>
</application>
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/holo_blue_light"
app:navigationIcon="@drawable/back_navigation_icon" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.