2017-11-22 17 views
0

私は自分のカスタムツールバーを設定し、 "setHomeButtonEnabled"と "setDisplayHomeAsUpEnabled"をtrueに設定し、ツールバーに実際の戻るボタンを表示しません。私は、カスタムアイコンを設定し、フラグメントが変更されているときにツールバーをクリックしてツールバーを表示しようとしたが、ツールバーは常に表示されますが、バックドロップは表示されません。私の登録活動が呼び出されていない可能性はありますか?フラグメントのツールバーの戻るボタンが表示されない

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); 
} 

断片が行く活動

<?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> 

私のマニフェスト

<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> 
+0

'代わりAppCompatActivity''のBaseActivity'を拡張する理由 – Xenolion

答えて

0
<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" /> 
関連する問題