0
尋找解決方案。我需要根據文本更改項目顏色。 下面是我的來自ExpandableListAdapter的片段。它工作正常,但是當我上下滾動時,所有項目都具有相同的顏色。任何解決方案?ExpandableListView項目顏色
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final ListItem childText = (ListItem) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
final TextView txtListChild = (TextView) convertView.findViewById(R.id.lblListItem);
txtListChild.setText(childText.getName());
txtListChild.setTag(childText.getDocumentGuid());
txtListChild.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!txtListChild.getTag().equals("HEADER")) {
Toast.makeText(getApplicationContext(), "" + txtListChild.getTag(), Toast.LENGTH_LONG).show();
} else {
//header//
}
}
});
if(childText.getDocumentGuid().equals("HEADER")) {
txtListChild.setTextColor(context.getResources().getColor(R.color.color_accent));
}
return convertView;
}