1. Download our Official Android App: Forums for Android!

Apps CustomAdapter array issue

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

  1. Crowposse

    Crowposse Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    4
    Joined:
    Nov 12, 2013

    Nov 12, 2013
    4
    3
    6
    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?:)
     

    Advertisement

Share This Page

Loading...