我正在开发 Android 项目。我需要一些错误的帮助。我正在尝试更改列表中的文本颜色。它失败并出现错误:
05-16 15:15:19.867:E/AndroidRuntime(31408):致命异常:主要 05-16 15:15:19.867:E/AndroidRuntime(31408):java.lang.ClassCastException:android.widget.TwoLineListItem 无法转换到 android.widget.TextView
try {
mAdapter = new SimpleExpandableListAdapter(
this,
groupData,
android.R.layout.simple_expandable_list_item_2,
new String[] { FIRST, SECOND },
new int[] { android.R.id.text1, android.R.id.text2 },
childData,
android.R.layout.simple_expandable_list_item_2,
new String[] { FIRST, SECOND },
new int[] { android.R.id.text1, android.R.id.text2 }){
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
TextView tv = (TextView) super.getChildView(groupPosition, childPosition, isLastChild,convertView, parent);
//change color text of tv here
//tv.setTextColor(0xff00ff00);
return tv;
}
};
setListAdapter(mAdapter);
getExpandableListView().setOnChildClickListener(this);
}
catch(Exception exc) {
Log.e("Log", exc.toString());
}
知道如何解决吗?