@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ListViewItem item = items.get(position);
View vi=convertView;
if(position == 0) {
vi = inflater.inflate(R.layout.setting_twolinetext_checkbox, null);
TextView tvRowTitle = (TextView) vi.findViewById(R.id.tvRowTitle);
TextView tvRowDesc = (TextView) vi.findViewById(R.id.tvRowDesc);
CheckBox cbCheckBox = (CheckBox) vi.findViewById(R.id.cbRowCheckBox);
tvRowTitle.setText(item.Title);
tvRowDesc.setText(item.Description);
return vi;
} else {
TwoLineListItem twoLineListItem = (TwoLineListItem) vi; <----- here is the error
TextView text1 = twoLineListItem.getText1();
TextView text2 = twoLineListItem.getText2();
text1.setText(item.Title);
text2.setText(item.Description);
return vi;
}
}
07-10 13:55:37.082: E/AndroidRuntime(10520): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TwoLineListItem
07-10 13:55:37.082: E/AndroidRuntime(10520): at com.example.util.CustomSettingsListViewAdapter.getView(CustomSettingsListViewAdapter.java:69)
有这个问题的其他人只是清理他们的项目并且它可以工作......也许我的问题是不同的。关于它为什么会给我这个问题的任何想法?