Android Open Source - AndroidSimplifiedDrawer Drawer Adapter






From Project

Back to project page AndroidSimplifiedDrawer.

License

The source code is released under:

MIT License

If you think the Android project AndroidSimplifiedDrawer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kokhouser.simplifieddrawer.library;
/*from  ww w . j  a  va  2  s  .  c  o m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import java.util.List;

/**
 * Created by HZKok on 7/7/2014.
 */

public class DrawerAdapter extends ArrayAdapter<Item> {
    private List<Item> items;
    private LayoutInflater inflater;

    public enum RowType {
        // Here we have two items types, you can have as many as you like though
        LIST_ITEM, PROFILE_ITEM, LIST_SUBITEM
    }

    public DrawerAdapter(Context context, LayoutInflater inflater, List<Item> items) {
        super(context, 0, items);
        this.items = items;
        this.inflater = inflater;
    }

    @Override
    public int getViewTypeCount() {
        // Get the number of items in the enum
        return RowType.values().length;

    }

    @Override
    public int getItemViewType(int position) {
        // Use getViewType from the Item interface
        return items.get(position).getViewType();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // Use getView from the Item interface
        return items.get(position).getView(inflater, convertView);
    }
}




Java Source Code List

com.kokhouser.librarysample.app2.ApplicationTest.java
com.kokhouser.librarysample.app2.MainActivity.java
com.kokhouser.simplifieddrawer.library.ApplicationTest.java
com.kokhouser.simplifieddrawer.library.DrawerActivity.java
com.kokhouser.simplifieddrawer.library.DrawerAdapter.java
com.kokhouser.simplifieddrawer.library.DrawerItem.java
com.kokhouser.simplifieddrawer.library.DrawerManager.java
com.kokhouser.simplifieddrawer.library.Item.java