I am writing a generic java-android function that will accept as one of it's parameters an ArrayList<Object>
, so that I can use all over my application regardless of the type of the ArrayList elements.
This is my function:
public GenericDisplayAdapter(Activity activity, ArrayList<Object> arrData) {
this.m_ArrData = arrData;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
When I try to to pass my ArrayList<CustomObject>
as a parameter to this function, I get the error "can't cast from ArrayList<CustomObject>
to ArrayList<Object>
",
m_LVStructDamageHeader.setAdapter(new GenericDisplayAdapter(
(Activity)this, (ArrayList<Object>)arrStructDamageHeaders));
What is the best approach to handle such a situation, Thanks