Debian Codegraph @

android/src/com/reecedunn/espeak/ResourceIdListAdapter.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2013 Reece H. Dunn
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 }