Ich habe meine Android-App mit einer Schublade Navigationsmenü eingerichtet und nach all dem Einrichten meiner App zeigt nur einen weißen leeren Bildschirm ohne meine LAUNCHER Aktivität und ohne nichts zu tun.Android App weißer Bildschirm blockiert ohne Fehler
Ich weiß, ist ziemlich veraltet, aber ich kann nicht herausfinden, was schief läuft, auch weil ich keine Log-Fehler habe .. ich denke, ist ein Problem des Themings, ich werde einige Code unten posten.
Danke für die Hilfe.
Theme.xml
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="AppTheme.CAFTracker" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:windowBackground" >@color/white</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/colorPrimary</item>
<item name="android:textColor">@color/colorPrimary</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="elevation">0dp</item>
</style>
<style name="ActionBarText" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textSize">20dp</item>
<item name="android:textColorPrimary">@android:color/white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.CAFTracker">
<activity
android:name=".gui.activity.HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
ActivityDefault.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/screen_default_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/screen_default_content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/screenToolbar"
style="@style/toolbar"
tools:context=".ToolBar" />
</RelativeLayout>
<FrameLayout
android:id="@+id/screen_default_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FrameLayout" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationMenu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
Hause Aktivität
public class HomeActivity extends Base {
public static Intent getHomeActivity(Context context){
return new Intent(context, HomeActivity.class);
}
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.add(R.id.screen_default_container, HomeFragment.newInstance(), AppConfig.FRAGMENT_HOME)
.commit();
}
}
@Override
protected int getContentView() {
return R.layout.activity_default;
}
@Override
protected int getTitleToolBar() {
return R.string.homeSectionName;
}
}
BaseActivity
public abstract class Base extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
@Bind(R.id.navigationMenu)
NavigationView mNavigationView;
@Bind(R.id.screen_default_drawer_layout)
DrawerLayout mDrawerLayout;
@Bind(R.id.screenToolbar)
protected Toolbar mToolBar;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(getContentView());
ButterKnife.bind(this);
CAFTrackerApplication.get(getApplicationContext()).inject(this);
}
@Override
protected void onStart() {
super.onStart();
if (mNavigationView != null) {
mNavigationView.setNavigationItemSelectedListener(this);
for (int menuItemPos = 0; menuItemPos < mNavigationView.getMenu().size(); menuItemPos++) {
if (mNavigationView.getMenu().getItem(menuItemPos).getItemId()
== Prefs.getIntPreference(getApplicationContext(), R.string.pref_ui_menu_selected)) {
mNavigationView.getMenu().getItem(menuItemPos).setChecked(true);
break;
}
}
}
loadInfoToolbar();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (mDrawerLayout != null) {
mDrawerLayout.openDrawer(GravityCompat.START);
}
return true;
}
return super.onOptionsItemSelected(item);
}
public void loadInfoToolbar() {
setSupportActionBar(mToolBar);
try {
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setShowHideAnimationEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
getSupportActionBar().setTitle(getTitleToolBar());
}
} catch (NullPointerException e) {
Logger.e("Support action bar is null");
}
}
@Override
protected void onDestroy() {
super.onDestroy();
ButterKnife.unbind(this);
}
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
Logger.i("Position clicked [ " + menuItem.getItemId() + " ]");
Prefs.savePreference(getApplicationContext(), R.string.pref_ui_menu_selected, menuItem.getItemId());
//Closing drawer on item click
if (mDrawerLayout != null) {
mDrawerLayout.closeDrawers();
}
switch (menuItem.getItemId()) {
// Sub Sections
case R.id.nav_home:
startActivity(HomeActivity.getHomeActivity(getApplicationContext()));
return true;
}
return false;
}
protected abstract int getContentView();
protected abstract int getTitleToolBar();
}
Warum sind Sie nicht HomeActivity? –
Sicher, ich werde HomeActivity und die BaseActivity hinzufügen! Hier sind Sie – dvdciri