The app is supposed to have a navigation drawer that pulls out from the left and shows the various activities, but once the navigation bar is added to the XML activity_homescreen doc, the app crashes as soon as it starts.
HomeScreen.java
package com.t99sdevelopment.centralized;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Toolbar;
public class HomeScreen extends AppCompatActivity {
/*
Intent intentHome = new Intent(this, HomeScreen.class);
Intent intentAnnouncements = new Intent(this, AnnouncementsScreen.class);
Intent intentSchedule = new Intent(this, ScheduleScreen.class);
Intent intentCalendar = new Intent(this, CalendarScreen.class);
Intent intentContactBook = new Intent(this, ContactBookScreen.class);
Intent intentSportsSchedule = new Intent(this, SportsScheduleScreen.class);
Intent intentFrontAndCentral = new Intent(this, FrontAndCentralScreen.class);
Intent intentMap = new Intent(this, MapScreen.class);
Intent intentAccount = new Intent(this, AccountScreen.class);
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homescreen);
setTheme(R.style.AppTheme);
}
/*
private void goToHome(View view){ startActivity(intentHome ); }
private void goToAnnouncements(View view){ startActivity(intentAnnouncements ); }
private void goToSchedule(View view){ startActivity(intentSchedule); }
private void goToCalendar(View view){ startActivity(intentCalendar); }
private void goToContactBook(View view){ startActivity(intentContactBook); }
private void goToSportsSchedule(View view){ startActivity(intentSportsSchedule); }
private void goToFrontAndCentral(View view){ startActivity(intentFrontAndCentral); }
private void goToMap(View view){ startActivity(intentMap); }
private void goToAccount(View view){ startActivity(intentAccount); }
*/
}
activity_homescreen.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar"
android:background="@color/trojanBlack">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/actionbar" />
<ImageView
android:id="@+id/ImageView_trojanHead"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="150dp"
android:src="@drawable/trojan"
android:scaleType="centerCrop" />
<TextView
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_marginTop="100dp"
android:text="School is"
android:paddingTop="5dp"
android:textSize="30sp"
android:textColor="@color/trojanBlack"
android:textAlignment="center"
android:background="@drawable/schoolbutton"
android:radius="5dp"/>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_marginTop="-100dp">
<Button
android:layout_width="25dp"
android:layout_height="25dp"
android:background="@drawable/refresh"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:text="OPEN"
android:textSize="40sp"
android:textColor="@color/trojanBlack"
android:textAlignment="center"
android:paddingTop="45dp" />
</RelativeLayout>
<TextView
android:layout_width="250dp"
android:layout_height="50dp"
android:background="#FFFFFF"
android:layout_marginTop="10dp" />
<FrameLayout
android:id="@+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
app:menu="@menu/navigationdraweritems"
app:headerLayout="@layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
With these files as is, the app crashes, but if I change the activity_homescreen.xml as follows (commenting out the navigation view widget)...
activity_homescreen.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar"
android:background="@color/trojanBlack">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/actionbar" />
<ImageView
android:id="@+id/ImageView_trojanHead"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="150dp"
android:src="@drawable/trojan"
android:scaleType="centerCrop" />
<TextView
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_marginTop="100dp"
android:text="School is"
android:paddingTop="5dp"
android:textSize="30sp"
android:textColor="@color/trojanBlack"
android:textAlignment="center"
android:background="@drawable/schoolbutton"
android:radius="5dp"/>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_marginTop="-100dp">
<Button
android:layout_width="25dp"
android:layout_height="25dp"
android:background="@drawable/refresh"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:text="OPEN"
android:textSize="40sp"
android:textColor="@color/trojanBlack"
android:textAlignment="center"
android:paddingTop="45dp" />
</RelativeLayout>
<TextView
android:layout_width="250dp"
android:layout_height="50dp"
android:background="#FFFFFF"
android:layout_marginTop="10dp" />
<FrameLayout
android:id="@+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!--
<android.support.design.widget.NavigationView
android:id="@+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
app:menu="@menu/navigationdraweritems"
app:headerLayout="@layout/nav_header" />
-->
</android.support.v4.widget.DrawerLayout>
Everything works just fine, with the exception of the navigation drawer not being included/working. Has anyone had this issue, or even better, does anyone know how to fix it? I need the navigation drawer working, but it seems to crash my app.
The logcat spilled over the maximum number of characters, so here's the github gist.