Debian Codegraph @

android/src/com/reecedunn/espeak/FileListAdapter.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 import java.io.File;
27
28 public class FileListAdapter extends ArrayAdapter<File>
29 {
30 private final LayoutInflater mInflater;
31
32 static class ViewHolder
33 {
34 public TextView text;
35 }
36
37 public FileListAdapter(Activity context, File[] resources)
38 {
39 super(context, android.R.layout.simple_list_item_1, resources);
40 mInflater = context.getLayoutInflater();
41 }
42
43 @Override
44 public View getView(int position, View convertView, ViewGroup parent)
45 {
46 ViewHolder holder;
47 if (convertView == null)
48 {
49 convertView = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
50 holder = new ViewHolder();
51 holder.text = (TextView)convertView.findViewById(android.R.id.text1);
52 convertView.setTag(holder);
53 }
54 else
55 {
56 holder = (ViewHolder)convertView.getTag();
57 }
58
59 File file = getItem(position);
60 holder.text.setText(file.getName());
61 return convertView;
62 }
63
64 @Override
65 public View getDropDownView(int position, View convertView, ViewGroup parent)
66 {
67 return getView(position, convertView, parent);
68 }
69 }