我对 Android 很陌生,我想在 Listview 中更改 TextView 的文本颜色。尝试这个时,颜色不会改变。谁能帮我解决这个(简单的?)问题?
我在“BaseAdapter”中使用以下代码来控制 ListView:
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = mInflater.inflate(R.layout.cijfer_listitem, null);
holder = new ViewHolder();
holder.mCijferTxt = (TextView) view.findViewById(R.id.cijferTxt);
holder.mVakTxt = (TextView) view.findViewById(R.id.vakTxt);
holder.mVakUitgebreidTxt = (TextView) view.findViewById(R.id.vakUitgebreidTxt);
holder.mIdTxt = (TextView) view.findViewById(R.id.idTxt);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
Cijfer cijfer = mCijfers.get(i);
holder.mCijferTxt.setText(cijfer.getCijfer());
holder.mVakTxt.setText(cijfer.getCursus());
holder.mVakUitgebreidTxt.setText(cijfer.getCursusUitgebreid());
holder.mIdTxt.setText("" + cijfer.getCijferID());
if (cijfer.isDef() == true ){
holder.mCijferTxt.setTextColor(R.color.colorTxtDef);
}
else{
holder.mCijferTxt.setTextColor((R.color.colorTxtConcept));
}
return view;
}
public class ViewHolder {
public TextView mCijferTxt;
public TextView mVakTxt;
public TextView mVakUitgebreidTxt;
public TextView mIdTxt;
}
我想更改 TextView“cijferTxt”的颜色。
希望这是足够的信息来帮助我:)