1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

there are no way to have these two lists?
It's easier to have them in one list as the index in that list will be your adapter index, but with some clever math you could have multiple lists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.