코드 구조 나는 ListAdapter에 DeviceList를 전달하려는는
public interface ListItem
public abstract class Device implements ListItem
public class DeviceList extends ArrayList<Device>
public class ListAdapter extends BaseAdapter{
...
public ArrayList<ListItem> items;
...
}
인터페이스의 ArrayList에 ArrayList에 클래스를 캐스팅 할 수 없습니다 만,> <을 ListItem을 위해 ArrayList DeviceList 캐스팅 수 없습니다. 왜 그런가요?
Device가 ListItem을 구현하고 DeviceList가 Device의 배열 목록 인 경우이를 캐스팅 할 수 없습니까?
나는 이런 식으로 시도 :
일반적인 오해의ArrayList<ListItem> list2 = (ArrayList<ListItem>) device_list;
devicelist 유형의 장치이며 ArrayList의이 유형을 listitem –
예입니다 만, 장치는을 ListItem을 구현 대답했다, 그래서 그것을 캐스팅 할 수 있어야한다? –