Giter Club home page Giter Club logo

androidslidemenu's Introduction

Preview

preview gif

How to use

  1. Use SlideMenuLayout as your list item view's root.
<com.zongzhan.slidemenu.SlideMenuLayout 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:layout_width="match_parent"
    android:layout_height="50dp"
    tools:context="com.zongzhan.androidslidemenu.MainActivity">

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical"
        android:background="#FFFFFF"
        tools:text="Two Menu" />
    <ImageView
        android:id="@+id/menu1"
        android:layout_width="50dp"
        android:padding="10dp"
        android:layout_height="match_parent"
        android:gravity="center"
        android:background="@color/colorPrimary"
        android:src="@android:drawable/ic_menu_share"/>
    <ImageView
        android:id="@+id/menu2"
        android:layout_width="50dp"
        android:padding="10dp"
        android:layout_height="match_parent"
        android:gravity="center"
        android:background="@color/colorPrimaryDark"
        android:src="@android:drawable/ic_menu_delete" />
</com.zongzhan.slidemenu.SlideMenuLayout>
  1. Extend SlideMenuItemViewHolder
class MyViewHolder extends SlideMenuItemViewHolder {
    TextView textView;
    public MyViewHolder(SlideMenuListAdapter adapter, View itemView) {
        super(adapter, itemView);
        textView = itemView.findViewById(R.id.text);
    }
    public void setText(String s) {
        textView.setText(s);
    }
}
  1. Extend SlideMenuAdapter
class MyAdapter extends SlideMenuListAdapter<MyViewHolder> {
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(this, LayoutInflater.from(parent.getContext()).inflate(R.layout.item2, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.setText(String.valueOf(position));
    }

    @Override
    public int getItemCount() {
        return 30;
    }

}
  1. Set the adapter to your recycler view.

androidslidemenu's People

Contributors

kangzongzhan avatar

Stargazers

Goodness avatar  avatar

Watchers

James Cloos avatar  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.