Reputation: 326
Context : I Have a model Book that contains 1 ArrayList of type Flight, the flight model contains an array of legs.
Question: I need to show all legs in one listView, but i need it separated by flight, each flight should have a header with the departure date. The problem i'm facing is that in the adapter i can't access booth data models. For example in IOS i can show it with the indexPath, indexpath.section for flights and indexPath.row for the legs, i'm looking for something like a UITableViewController.
Here is what i already have.
public int getCount() {
return bookingsDetailModel.getFlights().size();
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
SILeg leg = bookingsDetailModel.getFlights().get(position).getFlightLegs()[position];
return viewHolder;
}
I'm only able to access one leg of each flight, and each flights can have more than 2 legs.
Any Help will be much appreciated
Upvotes: 1
Views: 51
Reputation: 3110
You'll need to generate 1 List of both your Flight and Leg models in order.
Then implement the getViewType method in your adapter to return different view types for your header and child views. Using this you can inflate different views for each type.
Upvotes: 1