• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps CustomAdapter array issue

Crowposse

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

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones