5 Comments

  1. CatsVsDogs Club
    il y a 2 minutes (modifié)
    Thnx,but i got this error: java.lang.ClassCastException: com.google.android.gms.ads.AdView cannot be cast to com.codestringz.recyclerviewadmobbanner.Country (i getting json data from an url using Volley)

    Logcat take me to this line in MyRecyclerViewAdapter: Country country = (Country) mList.get(position);

    So please help me with this, thank you bro

    1. Hi, Thank you for asking.
      You are casting AdView class to County class, that’s why you are getting this error. Could you please check the list of data in the mList by debugging the app. Place a debug point at MyRecyclerViewAdapter: Country country = (Country) mList.get(position); and check that mList.get(position) is instance of country class or AdView class.

      Also check return value of the getItemViewType method.

      @Override
      public int getItemViewType(int position)
      {
      	if (position == 0 || mList.get(position) instanceof Country)
      	{
      		return ITEM_TYPE_COUNTRY;
      	} else
      	{
      		return (position % MainActivity.ITEMS_PER_AD == 0) ? ITEM_TYPE_BANNER_AD : ITEM_TYPE_COUNTRY;
      	}
      }
      

      If you are still getting the error, don’t hesitate to contact here. Thank you. Happy coding!

  2. How to set banner ads in RecyclerView in GridLayoutManager.
    I want to show Admob banner ads after 6 item in recyclerview. I have added banner after 6 item but it is not shown properly. it shows after 6 item but could not show in complete width of the mobile.

Leave a Reply