Android Open Source - BaseConverterPlus Navigation Drawer Adapter






From Project

Back to project page BaseConverterPlus.

License

The source code is released under:

MIT License

If you think the Android project BaseConverterPlus 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 codemonkey800.org.baseconverter.adapters;
//ww  w.  j  a  v a2s .  c o m
import android.content.Context;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import codemonkey800.org.baseconverter.R;
import codemonkey800.org.baseconverter.models.NavigationDrawerListItem;

public class NavigationDrawerAdapter extends BaseAdapter {

    private Context                               mContext;
    private ArrayList< NavigationDrawerListItem > mDrawerItems;

    public NavigationDrawerAdapter( Context context, ArrayList< NavigationDrawerListItem > drawerItems ) {
        mContext = context;
        mDrawerItems = drawerItems;
    }

    @Override
    public int getCount() {
        return mDrawerItems.size();
    }

    @Override
    public Object getItem( int position ) {
        return mDrawerItems.get( position );
    }

    @Override
    public long getItemId( int position ) {
        return position;
    }

    @Override
    public View getView( int position, View convertView, ViewGroup parent ) {
        if( convertView == null ) {
            LayoutInflater inflater = ( ( ActionBarActivity ) mContext ).getLayoutInflater();
            convertView = inflater.inflate( R.layout.layout_nav_drawer_item, null );
        }

        ImageView icon = ( ImageView ) convertView.findViewById( R.id.drawer_item_icon );
        TextView title = ( TextView ) convertView.findViewById( R.id.drawer_item_title );

        icon.setImageResource( mDrawerItems.get( position ).getIcon() );
        title.setText( mDrawerItems.get( position ).getTitle() );

        return convertView;
    }
}




Java Source Code List

codemonkey800.org.baseconverter.BaseConverterTest.java
codemonkey800.org.baseconverter.activities.BaseActivity.java
codemonkey800.org.baseconverter.activities.MainActivity.java
codemonkey800.org.baseconverter.adapters.NavigationDrawerAdapter.java
codemonkey800.org.baseconverter.fragments.ArbitraryBaseConverterFragment.java
codemonkey800.org.baseconverter.fragments.BaseConverterFragment.java
codemonkey800.org.baseconverter.fragments.BinaryConverterFragment.java
codemonkey800.org.baseconverter.fragments.DecimalConverterFragment.java
codemonkey800.org.baseconverter.fragments.HexadecimalConverterFragment.java
codemonkey800.org.baseconverter.models.BaseConverter.java
codemonkey800.org.baseconverter.models.NavigationDrawerListItem.java