有以下课程:
private class SimpleExistedTasksAdapter<CalendarTask> extends ArrayAdapter<CalendarTask> {
private Context context;
private List<CalendarTask> tasks;
public SimpleExistedTasksAdapter(Context context,
int textViewResourceId, List<CalendarTask> objects) {
super(context, textViewResourceId, objects);
this.context=context;
this.tasks=objects;
}
@Override
public View getView(int position, View view, ViewGroup group) {
LayoutInflater inflater=LayoutInflater.from(context);
View v=inflater.inflate(R.layout.existed_tasks_item_layout, null);
CalendarTask task=tasks.get(position);
TextView priorityView=(TextView)v.findViewById(R.id.textViewPriorityColorIndicator);
TextView title=(TextView)v.findViewById(R.id.textViewTaskTitle);
task.getPriority();
return null;
}
}
我遇到了以下问题:CalendarTask类有getPriority()方法,但是Eclipse告诉我“task”只是对象而且不包含任何方法exсept对象的(CalendarTask有导入)。
答案 0 :(得分:-1)
自从我搞砸Java以来已经有一段时间了,但是检查CalendarTask.get方法的返回类型。我怀疑你可能需要在行中执行从Object到CalendarTask的转换:
CalendarTask task=tasks.get(position);
如果我没记错的话,代码看起来像这样:
CalendarTask task = (CalendarTask)tasks.get(position);