0

First of all, my final goal is to dynamically create a hamburger menu for an android app. The hamburger menu needs to have main menu items, that each have a set of sub menu items.

However, before I get there I'm simply trying to create a simple listview display of the menu items. Each menu items contain a string (label) and list of string (label) / guid combinations.

I have my ViewModel containing the following:

public MvxObservableCollection<MenuItem> MenuItems { get; private set; }

public class MenuItem
{
    public MenuItem(string title)
    {
        Title = title;
    }

    public string Title { get; private set; }
}

My View axml definition looks like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <android.support.design.widget.AppBarLayout
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:id="@+id/toolbar_layout">
    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        local:layout_scrollFlags="scroll|enterAlways" />
  </android.support.design.widget.AppBarLayout>
    <Mvx.MvxListView
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          local:MvxItemTemplate="@layout/listitem_mainmenu"
          local:MvxBind="ItemsSource MenuItems" />
</RelativeLayout>

The listitem_mainmenu.axml definition looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textSize="20dp"
      local:MvxBind="Text Title; Click ShowDashboard" />
</LinearLayout>

I've debugged and verified that my MenuItems collection does contain 8 items. However, when the display is presented nothing is displayed in the emulation device.

Any suggestions on: 1) getting this list of items to show up, and 2) ultimately converting this to a hamburger menu would be appreciated.

BermudaLamb
  • 273
  • 3
  • 5
  • 24
  • Hi, in this [case](https://stackoverflow.com/questions/48868004/xamarin-android-coordinatorlayout-hide-show-another-layout-than-toolbar), there is a project on [github](https://github.com/pinkysek/XabluDemoApp), you can download it and compare with yours. There is many views in his `AppBarLayout`, you can ignore it and to check his listview. – Robbit Mar 05 '18 at 10:18
  • Thank you the sample looks pretty deep. I see though that it is using MvvmCross 4.x and referencing a bunch of other technologies. v5 focuses more on views and viewModels for consistency, rather than activities (android specific). If there is an MvvmCross 5.x version that really covers and explains the features and usages for both Android and iOS, in a more digestible format that would be helpful. Looking through code is great, when you under the context of what you're seeing. – BermudaLamb Mar 05 '18 at 18:15
  • Hi, in your `listitem_mainmenu.axml`, change `LinearLayout`'s height to `wrap_content`, or per item will fill the full screen. Try to set color for you `TextView`. And set different background for you `TextView` and `listitem_mainmenu. Above just to test something. [Here](https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/DailyDilbert/DailyDilbert.Droid/Resources/Layout/ListItem_Dilbert.axml) is official sample, I think you show download it and run . – Robbit Mar 06 '18 at 08:48
  • The "official sample" doesn't work. I'm using MvvmCross 5.2.1, Cirrious is part of an earlier release. – BermudaLamb Mar 07 '18 at 05:30

1 Answers1

0

fill_parent is deprecated. Use match_parent instead like you did in the RelativeLayout.

Raimo
  • 1,494
  • 1
  • 10
  • 19