• 14
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I have created a navigation view for my android app however I receive the following error when the activity attempts to launch and crash.

I've looked at other users similar issues but I still can't pinpoint the issue.

Any assistance would be greatly appreciated.

The logcat also points to line 60 of task_list.java which is the:

setContentView(R.layout.navigation_drawer);

This was originally pointing to a basic xml activity.

Binary XML file line #13: Binary XML file line #13: Error inflating 
class android.support.design.widget.NavigationView

Navigation_drawer.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include layout="@layout/task_list"/>

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/navigation_header"
    app:menu="@menu/navigation_menu">
</android.support.design.widget.NavigationView>

navigation_header.xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="160dp"
android:padding="16dp"
android:gravity="bottom"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:background="@drawable/background">


<de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:src="@drawable/accountimagecolor"
    android:scaleType="centerCrop"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Alex"
    android:paddingTop="8dp"
    android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/emailAlex"
    android:padding="4dp"

android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1"/>


</LinearLayout>

v21/styles.xml

<resources>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="actionBarPopupTheme">@style/PopupTheme</item>
    <item name="android:navigationBarColor">@color/colorPrimary</item>
</style>

<style name="PopupTheme" parent="Theme.AppCompat.Light">
    <item name="android:background">@color/background</item>
    <item name="android:textColor">@color/black</item>
</style>

</resources>

task_list.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.navigation_drawer);

    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("Portstewart - SuperValu Task List");

    drawerLayout = findViewById(R.id.drawerLayout);
    navigationView = findViewById(R.id.navigation_view);

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_drawer, R.string.close_drawer);
    drawerLayout.setDrawerListener(toggle);

    toggle.syncState();

gradle

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'

implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.firebaseui:firebase-ui-database:4.2.1'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
}

apply plugin: 'com.google.gms.google-services'
      • 2
    • @Swati I can see the navigation bar now with no errors now thanks, how would I show the navigation menu now but?
    • I think the problem is in navigation_menu. So,now add that line again .and in your item list add item one by one and check from which item error is generated
    • @Swati yes you're right I hadn't structured navigation_menu properly (something to do with not containing a second menu within an item) everything is working now as it should be thanks for your help!

Issue had arisen from navigation_menu xml

Originally the second menu (Advanced options) was not contained within an item.

This is the correct layout

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<group android:checkableBehavior="single">

    <item
        android:title="Complete"
        android:id="@+id/complete">
    </item>
    <item
        android:title="In-Progress"
        android:id="@+id/inProgress">
    </item>
    <item
        android:title="Not Started"
        android:id="@+id/notStarted">
    </item>
</group>

<item android:title="Advanced Options">

    <menu>

        <item
            android:title="Other Items"
            android:id="@+id/other">
        </item>

    </menu>

</item>


 </menu>
  • 1
Reply Report

Remove below line and run it

" <item name="android:textColor">@color/black</item>"
  • 0
Reply Report
      • 2
    • @Abr I have fixed the issue, please see the comments in initial post at the top and I have provided the answer with update navigation_menu.xml below. I'd appreciate it if you could mark the below answer as correct and upvote please. Thanks for your input.