好的,到目前为止我已经创建了这个,并且我的项目正在显示。假设我在一个数组中拥有与行一样多的元素的键值。如果我有 16 行,那么我的数组有 16 个元素。我想检查 array[0] 并根据值 setColor 到第一行,然后检查 array[1] 和 setColor 到下一行,依此类推。谁能帮我:
public class SimpleAdapter extends ArrayAdapter<String>{
private final Context context;
private String data[] = null;
public SimpleAdapter(Context context, String[] data) {
super(context, R.layout.row, data);
this.context = context;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.row, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.text1);
textView.setText(data[position]);
return rowView;
}
}