我正在为公交车站创建应用程序,以提供时间表。为此,我使用自定义列表视图。那就是:自定义ListView - 自定义参数
class custom_adapter extends ArrayAdapter<String>{
public custom_adapter(Context context, ArrayList<String> horarios) {
super(context, R.layout.costum_listview ,horarios);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater horarioInflater = LayoutInflater.from(getContext());
View costumView = horarioInflater.inflate(R.layout.costum_listview, parent, false);
String singleHorario = getItem(position);
TextView hora = (TextView) costumView.findViewById(R.id.Hora);
TextView nota = (TextView) costumView.findViewById(R.id.Nota);
hora.setText(singleHorario);
nota.setText(" ");
return costumView;
}
}
现在你可以看到我刚刚2 texViews然而,“霍拉”是显示总线的定时器,在“诺塔”是一些笔记,就像有一天公共汽车不去或者类似的东西一样。而我的问题正是在于“nota”textview。我有几十个arrayList传递给这个自定义的ListView,以及几十个和几十个定时器,并且有一些定时器需要放置一个便条,其他的我不需要。所以,我可以给这个自定义ListView另外一个参数,就像一个布尔值或者其他东西,所以我可以在该代码中做一个if/else来为每一个添加一个注释。为了做到这一点,我需要改变什么?我一直在努力,但并没有完全做到这一点。
但问题是,如果我必须传递一个类,那么这个类将不得不拥有ArrayList,但是我想放入的“nota”不是对所有Array的单个注释,而是一个注释, (或不)在数组的每一个项目中。不知道我能否更好地解释。如果我要放一个音符,我传递的数组中的每一项都将被检查。 –