FATAL EXCEPTION: main Process: com. explurger, PID: 22935 java.lang. NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference at com. Fragments.ExplurgerFragment$SIViewPager.instantiateItem(ExplurgerFragment. java:594) at android .support.v4.view.ViewPager.addNewItem(ViewPager.java:1004) at android .support.v4.view.ViewPager.populate(ViewPager.java:1152) at android .support.v4.view.ViewPager.populate(ViewPager.java:1086) at android .support.v4.view.ViewPager.onMeasure(ViewPager.java:1616) at android .view.View.measure(View.java:18580) at android .widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android .widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android .view.View.measure(View.java:18580) at android .widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android .widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android .view.View.measure(View.java:18580) at android .widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android .widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android .view.View.measure(View.java:18580) at android .view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827) at android .widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435) at android .widget.LinearLayout.measureVertical(LinearLayout.java:721) at android .widget.LinearLayout.onMeasure(LinearLayout.java:612) at android .view.View.measure(View.java:18580) at android .widget.ScrollView.measureChildWithMargins(ScrollView.java:2019)
Code- @Override public Object instantiateItem(ViewGroup container, int position) { View itemView = mLayoutInflater.inflate(R.layout.item_viewpager, container, false); ImageView imageView = (ImageView) itemView.findViewById(R.id. IMG_viewPager); RelativeLayout rr = itemView.findViewById(R.id.rr); SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager(). itemView.findFragmentById(R.id.map); mapFragment.getMapAsync(this); if (position == 0) { rr.setVisibility(View.VISIBLE); imageView.setVisibility(View.GONE); } else { rr.setVisibility(View.GONE); imageView.setVisibility(View.VISIBLE); String fileName = list.get(position-1).getImage(); Glide.with(mContext) .load(new File(fileName)).asBitmap().centerCrop() .placeholder(mContext.getResources().getDrawable(R. drawable.default_img)) .override(500, 500).fitCenter().into(imageView); // imageView.setImageResource(list.get(position).getImage()); } container.addView(itemView); return itemView; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/4df89600-03da-4275-ba32-2b77f0dadcba%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.