I want insert map fragment inside listview that use custom adapter
class TripAdapter
class TripAdapter extends ArrayAdapter<Trip> {
        private List<Trip> trips;
        public TripAdapter(@NonNull Context context, List<Trip> trips) {
            super(context, 0);
            this.trips = trips;
        }
        @Override
        public int getCount() {
            return trips.size();
        }
        @NonNull
        @Override
        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater()
                        .inflate(R.layout.custom_past, parent, false);
            }
            TextView dateText = convertView.findViewById(R.id.dateText);
            TextView timeText = convertView.findViewById(R.id.timeText);
            TextView startText = convertView.findViewById(R.id.startText);
            TextView endText = convertView.findViewById(R.id.endText);
            TextView nameText = convertView.findViewById(R.id.nameText);
            TextView notesText = convertView.findViewById(R.id.notesText);
            TextView statusText = convertView.findViewById(R.id.statusText);
            TextView typeText = convertView.findViewById(R.id.typeText);
            Button deleteButton = convertView.findViewById(R.id.deleteButton);
            MapFragment f = (MapFragment) getFragmentManager()
                    .findFragmentById(R.id.map);
            if (f != null)
                getFragmentManager().beginTransaction().remove(f).commit();
            Trip trip = trips.get(position);
            dateText.setText(trip.tripdate);
            timeText.setText(trip.triptime);
            nameText.setText(trip.name);
            notesText.setText("Notes: " + trip.notes);
            startText.setText(trip.starttext);
            endText.setText(trip.endtext);
            statusText.setText("(" + trip.status + ")");
            typeText.setText("(" + trip.type + ")");
            startlat = Double.valueOf(trip.startlat);
            startlongg = Double.valueOf(trip.startlongg);
            endlat = Double.valueOf(trip.endlat);
            endlongg = Double.valueOf(trip.endlongg);
            deleteButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                }
            });
            return convertView;
        }
    }
xml layout file
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#D6D5D5"
    tools:context=".UpcomingTrips">
    <fragment
        android:id="@+id/map"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="0dp"
        android:layout_height="150dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.494"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/notesText" />
</androidx.constraintlayout.widget.ConstraintLayout>
I want declare fragment inside TripAdapter I want when list contains more than one trip add them in TripAdapter and this is error java.lang.IllegalArgumentException: Binary XML file line #140: Duplicate id 0x7f08009d, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment at androidx.fragment.app.FragmentManagerImpl.onC
Thanks very much
User contributions licensed under CC BY-SA 3.0