Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Dynamically Adding MapView/SupportedMapFragment to CardView? #48

Open
rAndroidTest opened this issue Aug 16, 2017 · 0 comments
Open

Dynamically Adding MapView/SupportedMapFragment to CardView? #48

rAndroidTest opened this issue Aug 16, 2017 · 0 comments

Comments

@rAndroidTest
Copy link

rAndroidTest commented Aug 16, 2017

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant