1. Are you ready for the Galaxy S20? Here is everything we know so far!

CustomAdapter array issue

Discussion in 'Android Development' started by Crowposse, Dec 24, 2013.

  1. Crowposse

    Crowposse Lurker
    Thread Starter

    I have a CustomAdapter with the following constructor

    [HIGH]
    public TemperatureAdapter(Context context, int layoutResourceId, Temperature[] data) {
    super(context, layoutResourceId, data);
    this.layoutResourceId = layoutResourceId;
    this.context = context;
    this.data = data;
    }
    [/HIGH]

    This is being fed [HIGH]List<Temperature> temperatures [/HIGH] from a method in an Async task.

    and the adapter line is

    [HIGH]TemperatureAdapter adapter = new TemperatureAdapter(TemperatureActivity.this, R.layout.temperature_edit_row, (Temperature[]) ( temperatures.toArray());[/HIGH]

    My problem is:

    java.lang.Object[] cannot be cast to com.android.sentinelwater.SWObjects$Temperature[]

    The code complies but runtimes. Nothing I try works. I must be missing something, any Genii out there?:)
     


Loading...

Share This Page

Loading...