0
進出口使用下面的代碼使用過濾的ListView: How to dynamically update a ListView on Android定製ListAdapter用於過濾的ListView
,我試圖讓在ListView文本顏色爲黑色。顯然這隻能通過使用我之前製作的自定義適配器來完成。問題是如果我切換到自定義適配器,我的ListView沒有得到適當的篩選。有任何想法嗎?繼承人的代碼:
public class OffCampusStopsAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] names;
public OffCampusStopsAdapter(Context context, String[] names) {
super(context, R.layout.rowlayout, names);
this.context = context;
this.names = names;
}
@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.offcampusstopslayout, null, true);
TextView textView = (TextView) rowView.findViewById(R.id.stoplabel);
textView.setText(names[position]);
String s = names[position];
return rowView;
}
}