1

I am making a custom arrayAdapter for my listview, but a simple thing like my super constructor is messing me up!

private ArrayAdapter<ScheduleTime> timeHold;
    //make proper constructor, see use ticket types
    public TimeTableAdapter(Context context, int textViewResourceId,
            ArrayAdapter<ScheduleTime> timesTable) {
        super(context, textViewResourceId, timesTable);
        this.timeHold = timesTable;
    }

I get the error on the super line:

super(context, textViewResourceId, timesTable);

The constructor SimpleAdapter(Context, int, ArrayAdapter<ScheduleTime>) is undefined

What am I missing here? my above constructor clearly has all of those elements

1
  • When it says, The constructor SimpleAdapter(Context, int, ArrayAdapter<ScheduleTime>) is undefined, it means that those are the wrong elements. It is telling you that you have those elements, but that is not defined for a Simple Adapter. As @JB Nizet said, a Simple Adapter has different super arguments. Commented Aug 17, 2011 at 21:50

2 Answers 2

2

Just because the constructor you are defining takes a certain parameter list, it doesn't mean the super class has that constructor. After all, you can define any arbitary parameter list for your constructor.

The super constructor you are trying to call is closest to ones in the ArrayAdapter class, but the error message suggests you are trying to inherit from SimpleAdapter. Have you got this right? If it should be ArrayAdapter, the last argument needs to be the array (or List) of the objects which back the adapter, instead of just a single object of that type.

If it is SimpleAdapter, the only constructor is here, which looks quite a bit different.

Sign up to request clarification or add additional context in comments.

Comments

1

super is used to call the constructor of the superclass, the class you're extending. Look at the documentation: the constructor of SimpleAdapter has different arguments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.