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

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

    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?:)

    1. Download the Forums for Android™ app!



Share This Page