-1

i have a generic viewholder class for recyclerview which uses MapView inside that row, and the viewholder class is extending my base viewholder abstract class which has populateData(TO to), i am initializing map in the constructor of my viewholder class and passing null to mapview.onCreate(null).

my classes are look like this

public class MyViewHolder extends BaseViewHolder implements OnReadyMapCallBack{

   private MapView mapView;
   public MyViewHolder(View view){

       mapView = view.findViewById(R.id.map);
       mapView.onCreate(null); //here i should pass Bundle instead


      }
// this method is declared in parent class abstract class

@override    
public void populateData(TO to){ 
     mapView.getAsync(this);
}
 public void onMapReady(GoogleMap googleMap) {
}
}
kuldeep zala
  • 57
  • 3
  • 12

1 Answers1

0

enter image description hereYou trued this:

    Bundle args = new Bundle();
    args.putString("key",value);

    mapView.onCreate(args);

?

TzlilSwi
  • 94
  • 6
  • i have not tried this approach..i will try it definitely, thanks for reply. my only worry is the way i am integrating map view in non activity class could cause any bugs? because mapFragment is having its own life cycle and i am not using any of the method of life cycle. – kuldeep zala Apr 03 '17 at 10:53
  • Just follow this and put the bundle as I mentioned. If you implement all the lifecycle methods you will be ok! https://developers.google.com/android/reference/com/google/android/gms/maps/MapView.html#onCreate(android.os.Bundle) – TzlilSwi Apr 03 '17 at 11:23
  • but its a recyclerview holder which will be used by the time of inflating recyclerview row, so i have to configure implementation of map in viewholder itself not in any fragment. – kuldeep zala Apr 03 '17 at 12:28