|
1 | | -package de.vogella.android.listactivity; |
2 | | - |
3 | | -import android.app.Activity; |
4 | | -import android.view.LayoutInflater; |
5 | | -import android.view.View; |
6 | | -import android.view.ViewGroup; |
7 | | -import android.widget.ArrayAdapter; |
8 | | -import android.widget.ImageView; |
9 | | -import android.widget.TextView; |
10 | | - |
11 | | -public class MyArrayAdapter extends ArrayAdapter<String> { |
12 | | - private final Activity context; |
13 | | - private final String[] names; |
14 | | - |
15 | | - public MyArrayAdapter(Activity context, String[] names) { |
16 | | - super(context, R.layout.rowlayout, names); |
17 | | - this.context = context; |
18 | | - this.names = names; |
19 | | - } |
20 | | - |
21 | | - @Override |
22 | | - public View getView(int position, View convertView, ViewGroup parent) { |
23 | | - LayoutInflater inflater = context.getLayoutInflater(); |
24 | | - View rowView = inflater.inflate(R.layout.rowlayout, null, true); |
25 | | - TextView textView = (TextView) rowView.findViewById(R.id.label); |
26 | | - ImageView imageView = (ImageView) rowView.findViewById(R.id.icon); |
27 | | - String s = names[position]; |
28 | | - textView.setText(s); |
29 | | - if (s.startsWith("Windows7") || s.startsWith("iPhone") |
30 | | - || s.startsWith("Solaris")) { |
31 | | - |
32 | | - imageView.setImageResource(R.drawable.no); |
33 | | - } else { |
34 | | - imageView.setImageResource(R.drawable.ok); |
35 | | - } |
36 | | - |
37 | | - return rowView; |
38 | | - } |
39 | | -} |
| 1 | +package de.vogella.android.listactivity; |
| 2 | + |
| 3 | +import android.app.Activity; |
| 4 | +import android.view.LayoutInflater; |
| 5 | +import android.view.View; |
| 6 | +import android.view.ViewGroup; |
| 7 | +import android.widget.ArrayAdapter; |
| 8 | +import android.widget.ImageView; |
| 9 | +import android.widget.TextView; |
| 10 | + |
| 11 | +public class MyPerformanceArrayAdapter extends ArrayAdapter<String> { |
| 12 | + private final Activity context; |
| 13 | + private final String[] names; |
| 14 | + |
| 15 | + public MyPerformanceArrayAdapter(Activity context, String[] names) { |
| 16 | + super(context, R.layout.rowlayout, names); |
| 17 | + this.context = context; |
| 18 | + this.names = names; |
| 19 | + } |
| 20 | + |
| 21 | + @Override |
| 22 | + public View getView(int position, View convertView, ViewGroup parent) { |
| 23 | + LayoutInflater inflater = context.getLayoutInflater(); |
| 24 | + View rowView = inflater.inflate(R.layout.rowlayout, null, true); |
| 25 | + TextView textView = (TextView) rowView.findViewById(R.id.label); |
| 26 | + ImageView imageView = (ImageView) rowView.findViewById(R.id.icon); |
| 27 | + String s = names[position]; |
| 28 | + textView.setText(s); |
| 29 | + if (s.startsWith("Windows7") || s.startsWith("iPhone") |
| 30 | + || s.startsWith("Solaris")) { |
| 31 | + |
| 32 | + imageView.setImageResource(R.drawable.no); |
| 33 | + } else { |
| 34 | + imageView.setImageResource(R.drawable.ok); |
| 35 | + } |
| 36 | + |
| 37 | + return rowView; |
| 38 | + } |
| 39 | +} |
0 commit comments