java - IndexOutOfBoundsException in RecyclerAdapter with Multiple View Types -
i'm getting indexoutofboundsexception when attempting return view type function of position of data in array. have 2 sources of data. 1 advertisement, , other list of names , locations. need combine arrays 1 single array before processing in recycleradapter? i'd rather not, if in principle different types, i.e. images versus text. getitemcount() method returns summed size of 2 arrays. why getting exception? how can achieve desired result of showing data 2 different sources in 2 different view types? my main activity: public class mainactivity extends appcompatactivity { private arraylist<object> getpresidentsarraylist() { arraylist<object> items = new arraylist<>(); items.add(new president("george washington", "mount vernon")); items.add(new president("john adams", "braintree")); items.add(new president("thomas jefferson", "monticello")); items.add