If you think the Android project campus 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 lecho.app.campus.adapter;
//fromwww.java2s.comimport lecho.app.campus.R;
import lecho.app.campus.utils.NavigationDrawerItem;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
publicclass NavigationDrawerAdapter extends ArrayAdapter<NavigationDrawerItem> {
privatestaticfinal String TAG = "NavigationDrawerAdapter";
public NavigationDrawerAdapter(Context context, int resource, NavigationDrawerItem[] objects) {
super(context, resource, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (null == convertView) {
int itemType = getItemViewType(position);
if (NavigationDrawerItem.TYPE_TITLE == itemType) {
convertView = View.inflate(getContext(), R.layout.item_title_navigation_drawer, null);
} elseif (NavigationDrawerItem.TYPE_ITEM_UNDER_TITLE == itemType) {
convertView = View.inflate(getContext(), R.layout.item_under_title_navigation_drawer, null);
} else {
Log.e(TAG, "Returning default title view - Invalid drawer item type" + itemType);
convertView = View.inflate(getContext(), R.layout.item_title_navigation_drawer, null);
}
}
// TODO if there will be more views use ViewHolder.
TextView tv = (TextView) convertView.findViewById(R.id.text);
tv.setText(getContext().getString(getItem(position).stringRes));
return convertView;
}
@Override
publicint getItemViewType(int position) {
return getItem(position).type;
}
@Override
publicint getViewTypeCount() {
return NavigationDrawerItem.NUMBER_OF_ITEM_TYPES;
}
@Override
publicboolean isEnabled(int position) {
return NavigationDrawerItem.isItemClickable(getItemViewType(position));
}
}