Back to project page SELP2013.
The source code is released under:
License ======= This work is licensed under the BSD 2-clause license as follows. # BSD 2-clause license Copyright (c) 2013, Sky Welch All rights reserved. Redistribution and use in source and ...
If you think the Android project SELP2013 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.skywelch.selp2013; //from w w w .java 2 s . co m import java.util.List; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; public class DrawerListAdapter extends BaseAdapter { private Context mContext; private List<StringListItem> items; public DrawerListAdapter(Context mContext, List<StringListItem> items) { this.items = items; this.mContext = mContext; } @Override public int getCount() { return items.size(); } @Override public Object getItem(int position) { return items.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { StringListItem item = (StringListItem) getItem(position); if (item.isSection()) { // Use given convertView if it's the View we want (performance optimisation) if (convertView == null || convertView.findViewById(R.id.list_header_title) == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); convertView = inflater.inflate(R.layout.list_header, parent, false); } TextView section_text = (TextView) convertView.findViewById(R.id.list_header_title); section_text.setText(item.getText()); } else { // Use given convertView if it's the View we want (performance optimisation) if (convertView == null || convertView.findViewById(R.id.drawerText) == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); convertView = inflater.inflate(R.layout.drawer_list_item, parent, false); } StringListItem menuitem = (StringListItem) item; TextView drawertext = (TextView) convertView.findViewById(R.id.drawerText); drawertext.setText(menuitem.getText()); } return convertView; } }