Reputation: 1644
I cannot use Google Map inside a RecyclerView
. I need to show a map and give it some configurations.
<com.google.android.gms.maps.MapView
android:id="@+id/map_view"
android:layout_height="120dp"
android:layout_width="match_parent"
android:layout_marginTop="15dp"/>
My RecyclerView
:
@Override
public ShopInfoAdapter.ShopInfoViewHolder onCreateViewHolder(ViewGroup viewGroup) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.fragment_x, viewGroup,
false);
MyHolder holder = new MyHolder(view);
holder.mapView.getMapAsync(this);
return holder;
}
@Override
public void onMapReady(GoogleMap googleMap) {
if (mListener != null) {
mListener.onMapClick(googleMap);
}
}
public interface ItemListener {
void onMapClick(GoogleMap googleMap);
}
Note: I implement the interface and the problem is not implementing.
Upvotes: 4
Views: 6060
Reputation: 7686
The "map" have 2 parts: Ones are your settings and the 2nd part are the marker. The market can be set inside your adapter and give it some values like latitude/longitude, info window, wtc
Make a custom adapter for your recycler view and set your mapview widget in it. The values for latitude/longitude, etc can be dynamically get in from AsyncTask and give every row, with a map widget, the correct data.
Here is an example of custom adapter (including add, remove, etc) for RecyclerView http://www.101apps.co.za/index.php/articles/android-s-recyclerview-and-cardview-widgets.html mapview it's like any other widget and can be set there.
Upvotes: 2