Back to project page AutobusParma.
The source code is released under:
GNU General Public License
If you think the Android project AutobusParma listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * ? Copyright 2014 Bartolomeo Lombardi// ww w . ja va 2s . c om This file is part of AutobusParma. AutobusParma is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 1 of the License, or any later version. AutobusParma is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with AutobusParma. If not, see <http://www.gnu.org/licenses/>. */ package it.unipr.informatica.autobusparma.adapter; import it.unipr.informatica.autobusparma.R; import it.unipr.informatica.autobusparma.model.NavDrawerItem; import java.util.ArrayList; 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.ImageView; import android.widget.TextView; public class NavDrawerListAdapter extends BaseAdapter { private Context context; private ArrayList<NavDrawerItem> navDrawerItems; public NavDrawerListAdapter(Context context, ArrayList<NavDrawerItem> navDrawerItems){ this.context = context; this.navDrawerItems = navDrawerItems; } @Override public int getCount() { return navDrawerItems.size(); } @Override public Object getItem(int position) { return navDrawerItems.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); convertView = mInflater.inflate(R.layout.drawer_list_item, null); } ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon); TextView txtTitle = (TextView) convertView.findViewById(R.id.title); TextView txtCount = (TextView) convertView.findViewById(R.id.counter); imgIcon.setImageResource(navDrawerItems.get(position).getIcon()); txtTitle.setText(navDrawerItems.get(position).getTitle()); // displaying count // check whether it set visible or not if(navDrawerItems.get(position).getCounterVisibility()){ txtCount.setText(navDrawerItems.get(position).getCount()); }else{ // hide the counter view txtCount.setVisibility(View.GONE); } return convertView; } }