Jeff Sharkey の SeparatedListAdapterを使用していて、テキストの色を設定したいのですが、方法がわかりません。
アダプターの背景を説明するために、単純な Android リストに似た BaseAdapter をサブクラス化しました。だから、私はこのような方法でテキストの色を設定しようとしましたgetView()
(コメントセクションの間に私の試みを見ることができます):
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
int sectionnum = 0;
for(Object section : this.sections.keySet()) {
Adapter adapter = sections.get(section);
int size = adapter.getCount() + 1;
// check if position inside this section
if(position == 0) return headers.getView(sectionnum, convertView, parent);
if(position < size)
{
/***** I added this section to try to set the text color ***/
TextView captionTV = (TextView)adapter.getView(position, convertView, parent).findViewById(R.id.list_complex_caption);
captionTV.setTextColor(R.color.black;);
TextView titleTV = (TextView)adapter.getView(position, convertView, parent).findViewById(R.id.list_complex_title);
titleTV.setTextColor(R.color.black;);
/***** end add *****/
return adapter.getView(position - 1, convertView, parent);
}
// otherwise jump into next section
position -= size;
sectionnum++;
}
return null;
}
しかし、最初のセルのテキストの色を設定しますが、残りのセルには設定しません。
何か案は?