Ich habe ein Problem damit, dass meine Symbolleiste und Navigationsleiste in einer neuen Layoutdatei angezeigt wird. Es funktioniert für die gesamte App, mit Ausnahme der neuen Layoutansicht mit Registerkarten.Symbolleiste/Nav-Schublade funktioniert nicht mit Registerkartenansicht
ich versuche, es in der onCreate der neuen Java-Klasse zu aktivieren:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.workout_days);
mToolBar = activateToolbar();
setUpNavigationDrawer();
ich keinen Fehler mehr, aber die Symbolleiste zeigt immer noch nicht auf. Ich frage mich, ob etwas mit meiner Layoutdatei nicht stimmt.
baseactivity:
public static final int HOME = 1;
public static final int MY_WORKOUT = 2;
public static final int MAXES = 3;
public static final int PROGRESS = 4;
public static final int WORKOUTS = 5;
public static final int HELP = 6;
private Class mNextActivity;
public static String mTitle = AppConstant.SHIEKO_WORKOUT;
public static int mType = HOME;
protected Toolbar mToolBar;
private NavigationDrawerFragment mDrawerFragment;
protected Toolbar activateToolbar() {
if(mToolBar == null) {
mToolBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(mToolBar);
switch (mType) {
case HOME:
getSupportActionBar().setTitle(AppConstant.SHIEKO_WORKOUT);
break;
case MY_WORKOUT:
getSupportActionBar().setTitle(AppConstant.MY_WORKOUT);
break;
case MAXES:
getSupportActionBar().setTitle(AppConstant.SET_MY_MAXES);
break;
case PROGRESS:
getSupportActionBar().setTitle(AppConstant.MY_PROGRESS);
break;
case WORKOUTS:
getSupportActionBar().setTitle(AppConstant.WORKOUTS);
break;
case HELP:
getSupportActionBar().setTitle(AppConstant.FEEDBACK);
}
}
return mToolBar;
}
Hier ist meine Tätigkeit: Ich habe auch drei andere Fragment XML-Seiten haben, die für die drei Registerkarten sind, schließen diejenigen ein, nicht über die Symbolleiste oder Navigationsleiste, wie es mein Verständnis ist sie unter die sind TabView .. korrigiert mich wenn ich falsch liege bitte ..
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--<RelativeLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent">-->
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="0dp">
<include android:id="@+id/app_bar"
layout="@layout/toolbar" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<!--</RelativeLayout>-->
<fragment
android:name="com.bestworkouts.sheikoworkout.NavigationDrawerFragment"
android:id="@+id/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Vielen Dank im Voraus!
'findViewById (R.id.app_bar)' hat null zurückgegeben. Bitte überprüfen Sie, ob es in Ihrem XML-Layout existiert –
Es war da drin, aber ich habe es an einen anderen Ort verschoben. Jetzt bekomme ich keine Fehlermeldung, und die Tab-Ansicht ist unterhalb der Symbolleiste, aber sie wird immer noch nicht angezeigt :( – LBJ33
Kannst du [edit] mit einem [mcve], bitte? Es ist schwer zu sagen, wie diese beiden Codeschnipsel interagieren –