Code Monkey home page Code Monkey logo

yumamateriallistview's Introduction

YumaMaterialListView#

A Fast way to make list views for navigation drawers

###Usage in Android

This libarry is available as a maven respository on Bintray, to use it in your Android Project add the repo to your respositories in the app.gradle file

repositories {
  maven {
    url 'https://dl.bintray.com/yumashish/maven'
  }
}

Then you can add the library itself

dependancies {
  //various other libraries
  compile 'com.yumashish.yumamateriallistview:yumamateriallistview:1.0.1@arr'
}

###Example of usage in layout XML:###

<com.yumashish.yumamateriallistview.YumaMaterialListView
            android:id="@+id/drawer_listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="@color/colorPrimary"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            app:ysGroupTextColor="#fff"
            app:ysSeperatorTextColor="#ff0"
            app:ysChildTextColor="#0ff"
            app:ysSeperatorTextSize="10sp"
            app:ysGroupTextSize="12sp"
            app:ysChildTextSize="12dp"
            app:ysMenuItems="@menu/drawer_menu"
            app:ysSpecialView="@layout/demo_special"
            app:ysMenuSeperators="@array/drawer_categories_seperators">
</com.yumashish.yumamateriallistview.YumaMaterialListView>

###Attributes:###

ysMenuItems: The menu where the items for this listview are defined.

ysSpecialView: This is a view you can put on top of the actual menu list (User information, for example)

ysMenuSeperators: The seperators are smaller than normal cells/items

{$} := (Seperator|Group|Child)

ys{$}TextColor: The text color of all the {$}

ys{$}TextSize: The text size of all the {$}

ys{$}BackgroundColor: The background color of all the {$}

###Example of Menu:(drawer_menu.xml)###

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yuma="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/first" android:icon="@android:drawable/ic_delete" android:title="First" />
    <item android:id="@+id/second" android:icon="@android:drawable/ic_delete" android:title="Second" />
    <item android:id="@+id/third" android:icon="@android:drawable/ic_delete" android:title="Third" />
    <item android:id="@+id/fourth" android:icon="@android:drawable/ic_delete" android:title="Fourth" />
    <item android:id="@+id/fifth" android:icon="@android:drawable/ic_delete" android:title="Fifth" />
    <item android:id="@+id/sixth" android:icon="@android:drawable/ic_delete" android:title="Sixth">
        <menu>
            <item android:id="@+id/sixth_child" android:icon="@android:drawable/ic_dialog_alert" android:title="Child One"></item>
        </menu>
    </item>
</menu>

To define the seperators we create a string array having the string ids of the serperator rows (strings.xml)

<string-array name="drawer_categories_seperators">
     <item>first</item>
     <item>fourth</item>
</string-array>

###Handling Menu Touch and Long Touch###

Implement and set the RespondToID interface's Respond method. Respond accepts an int which represents the menu item's ID. There are default implementations that will will send the name of the menu item to Log.i.

YumaMaterialListView v = getViewRef();
v.setOnClickResponder(new RespondToID() {
    boolean Respond(int id) {
        switch(id) {
            case R.menu.first:
                  //TODO handle click event on menu item first
                  return true;
            default:
                  return true;
            }
    }
});

Same for long clicks

v.setOnLongClickResponder(new RespondToID() {
    boolean Respond(int id) {
        switch(id) {
            case R.menu.first:
                  //TODO handle long click event on menu item first
                  //TODO remember to consume the long click to prevent registering the click event as well
                  return true;
            default:
                  return false;
            }
    }
});

yumamateriallistview's People

Contributors

thundercraker avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.