Как я могу получить доступ к GoogleMap из RecyclerView.ViewHolder
У меня есть:
public class MapRowHolder extends RecyclerView.ViewHolder
{
public MapRowHolder(View view) {
super(view);
}
}
XML:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android.support.v7.cardview="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android.support.v7.cardview:cardBackgroundColor="@color/blue"
android.support.v7.cardview:cardCornerRadius="@dimen/card_corner"
android.support.v7.cardview:cardElevation="@dimen/card_elevation">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right|center_vertical"
android:gravity="center_vertical|right"
android:layout_width="fill_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="250dp"
android:tag="maps"
android:id="@+id/map_view_fragment" tools:context=".Map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_centerInParent="true"/>
</LinearLayout>
adapter:
public class MapAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
{
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
RecyclerView.ViewHolder mh;
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_row, viewGroup, false);
mh = (RecyclerView.ViewHolder)new PodatkiZaMapRowHolder(v);
return mh;
}
public void onBindViewHolder(RecyclerView.ViewHolder RowHolder, int polozaj) {
MapRowHolder mapRowHolder = (MapRowHolder)RowHolder;
}
}
Карта отображается корректно. И это уменьшено до всей земли. И позиционируется на 0,0 в центре.
Как я могу получить фрагмент карты (в ViewHolder)? Я хочу переместить камеру в другое место (я могу сделать это после того, как получу объект GoogleMap) Как и где мне получить объект GoogleMap?
Если я использую MapView вместо фрагмента карты, он работает, но не обновляет карту. Карта обновляется после того, как я нажимаю на карту несколько раз. С уважением, Алесь