| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.reecedunn.espeak; |
| 18 |
|
| 19 |
import android.app.Activity; |
| 20 |
import android.view.LayoutInflater; |
| 21 |
import android.view.View; |
| 22 |
import android.view.ViewGroup; |
| 23 |
import android.widget.ArrayAdapter; |
| 24 |
import android.widget.TextView; |
| 25 |
|
| 26 |
public class ResourceIdListAdapter extends ArrayAdapter<Integer> |
| 27 |
{ |
| 28 |
private final LayoutInflater mInflater; |
| 29 |
|
| 30 |
static class ViewHolder |
| 31 |
{ |
| 32 |
public TextView text; |
| 33 |
} |
| 34 |
|
| 35 |
public ResourceIdListAdapter(Activity context, Integer[] resources) |
| 36 |
{ |
| 37 |
super(context, android.R.layout.simple_list_item_1, resources); |
| 38 |
mInflater = context.getLayoutInflater(); |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public View getView(int position, View convertView, ViewGroup parent) |
| 43 |
{ |
| 44 |
ViewHolder holder; |
| 45 |
if (convertView == null) |
| 46 |
{ |
| 47 |
convertView = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false); |
| 48 |
holder = new ViewHolder(); |
| 49 |
holder.text = (TextView)convertView.findViewById(android.R.id.text1); |
| 50 |
convertView.setTag(holder); |
| 51 |
} |
| 52 |
else |
| 53 |
{ |
| 54 |
holder = (ViewHolder)convertView.getTag(); |
| 55 |
} |
| 56 |
|
| 57 |
holder.text.setText(getItem(position)); |
| 58 |
return convertView; |
| 59 |
} |
| 60 |
|
| 61 |
@Override |
| 62 |
public View getDropDownView(int position, View convertView, ViewGroup parent) |
| 63 |
{ |
| 64 |
return getView(position, convertView, parent); |
| 65 |
} |
| 66 |
} |