alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame^] | 1 | package com.savoirfairelinux.sflphone.adapters; |
| 2 | |
| 3 | import android.content.Context; |
| 4 | import android.view.LayoutInflater; |
| 5 | import android.view.View; |
| 6 | import android.view.ViewGroup; |
| 7 | import android.widget.BaseAdapter; |
| 8 | import android.widget.TextView; |
| 9 | |
| 10 | import com.savoirfairelinux.sflphone.R; |
| 11 | |
| 12 | public class MenuAdapter extends BaseAdapter{ |
| 13 | |
| 14 | private static final String TAG = MenuAdapter.class.getSimpleName(); |
| 15 | private Context mContext; |
| 16 | String categories[]; |
| 17 | |
| 18 | public MenuAdapter(Context c, String[] cat) { |
| 19 | mContext = c; |
| 20 | categories = cat; |
| 21 | } |
| 22 | |
| 23 | @Override |
| 24 | public View getView(int pos, View convertView, ViewGroup parent) { |
| 25 | View v = convertView; |
| 26 | |
| 27 | LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 28 | if (v == null) { |
| 29 | v = inflater.inflate(R.layout.item_menu, null); |
| 30 | } |
| 31 | |
| 32 | ((TextView) v.findViewById(R.id.menu_title_categorie)).setText(categories[pos]); |
| 33 | |
| 34 | return v; |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public int getCount() { |
| 39 | return categories.length; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public String getItem(int pos) { |
| 44 | return categories[pos]; |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public long getItemId(int arg0) { |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | } |