SwipeStack icon indicating copy to clipboard operation
SwipeStack copied to clipboard

Dynamically Adding MapView/SupportedMapFragment to CardView?

Open rAndroidTest opened this issue 8 years ago • 0 comments

How can I dynamically add mapview/supportedmapfragment to the CardView under getView in the Adapter? I attempted to add the following code:

@Override public View getView(final int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = getLayoutInflater().inflate(R.layout.card, parent, false); }

        TextView textViewCard = (TextView) convertView.findViewById(R.id.textViewCard);
        textViewCard.setText(mData.get(position));

         // NEW CODE ADDED
        FragmentManager fm = getChildFragmentManager();
        SupportMapFragment supportMapFragment =  SupportMapFragment.newInstance();
        fm.beginTransaction().replace(R.id.mapContainer, supportMapFragment).commit();

        return convertView;
    }

And in the card.xml file a FrameLayout was added like this:

    android:id="@+id/mapContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Even with the above changes, I am only able to get the Test message to print on the Swipe cards. I am looking to get a map on each of the cards that get created. Any help would be appreciated.

Thanks!

rAndroidTest avatar Aug 16 '17 18:08 rAndroidTest