为什么我在课堂上调用 context.getResources().getString(R.string.string) 时会出错?使用
context.getResources().getString(R.string.january);
只是给我
android.content.res.Resources$NotFoundException: String resource ID #0x7f06002e
这是完整的课程:
public class CustomCursorAdapter extends CursorAdapter{
@SuppressWarnings("deprecation")
public CustomCursorAdapter(Context context, Cursor c){
super(context, c);
}
@Override
public View newView(Context context, Cursor c, ViewGroup parent){
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View returnView = inflater.inflate(R.layout.row, parent, false);
return returnView;
}
public void bindView(View v, Context context, Cursor c){
TextView firstname, surname, bday;
firstname = (TextView) v.findViewById(R.id.firstnameTextView);
firstname.setText(c.getString(c.getColumnIndex(c.getColumnName(1))));
surname = (TextView) v.findViewById(R.id.surnameTextView);
firstname.append(" " + c.getString(c.getColumnIndex(c.getColumnName(2))));
bday = (TextView) v.findViewById(R.id.datepickerTextView);
bday.setText("\n" + context.getResources().getString(R.string.january));
}
}
为什么我会收到此错误?