title: RecyclerView in Fragments Error inflating class <unknown>
body: <p>I have a navigation drawer in main screen with couple fragments.
  In main (default) fragment I have 2 recyclerviews. In profile fragment, I have 3 recyclerviews within 3 tabs.</p>
  
  <p>Normally, I did not get "Error inflating" or "skipping layout" errors when I use Recyclerview, but I have always problem in fragments.</p>
  
  <p>In normal usage, its all okey but when I go inside and outside of fragments one by one, I got "Error inflating class" and it points to Adapter's onCreateViewHolder (view = Layoutinflater....)</p>
  
  <p><strong>Navigation Activity</strong></p>
  
  <pre><code>public class Page_Navigation extends AppCompatActivity
      implements NavigationView.OnNavigationItemSelectedListener {
  
  Fragment fragment;
  FragmentManager fragmentManager = getSupportFragmentManager();
  NavigationView navigationView;
  
  SharedPreferences mSharedPref;
  DrawerLayout drawer;
  private Tracker mTracker;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_page__navigation);
  
      //
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      TextView toolbar_head = findViewById(R.id.toolbar_head);
      ImageView toolbar_image = findViewById(R.id.toolbar_image);
      ImageView toolbar_profile = findViewById(R.id.toolbar_profile);
      drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      //
  
      AnalyticsApplication application = (AnalyticsApplication) getApplication();
      mTracker = application.getDefaultTracker();
      mTracker.setScreenName("page_navigation");
      mTracker.send(new HitBuilders.ScreenViewBuilder().build());
  
      //FIRST SETTINGS
      setSupportActionBar(toolbar);
      Typeface customFont = Typeface.createFromAsset(getAssets(), "Montserrat-Medium.ttf");
      toolbar_head.setTypeface(customFont);
  
      //Get Sessions
      mSharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
      String session_user_name = mSharedPref.getString("session_user_name", "");
      String session_user_photo = mSharedPref.getString("session_user_photo", "");
  
      //Navigation Drawer
      ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
              this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
      drawer.addDrawerListener(toggle);
      toggle.syncState();
  
      navigationView = (NavigationView) findViewById(R.id.nav_view);
      navigationView.setNavigationItemSelectedListener(this);
      navigationView.setItemIconTintList(null);
      //
  
      View headerView = navigationView.getHeaderView(0);
      TextView nav_userName = (TextView) headerView.findViewById(R.id.textView_nav_userName);
      CircleImageView imageView_navigation = (CircleImageView) headerView.findViewById(R.id.imageView_navigation);
      Glide.with(getApplicationContext()).load(session_user_photo).into(imageView_navigation);
      nav_userName.setText(session_user_name);
  
      headerView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              if (drawer.isDrawerOpen(Gravity.START)) {
                  drawer.closeDrawer(Gravity.START);
              }
  
              new Handler().postDelayed(new Runnable() {
                  @Override
                  public void run() {
                      showProfileFragment();
                  }
              }, 300);
          }
      });
  
  
      toolbar_image.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              drawer.openDrawer(GravityCompat.START);
          }
      });
  
      toolbar_profile.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Fragment fragment;
              FragmentManager manager = getSupportFragmentManager();
              fragment = new Nav_Profile();
              FragmentTransaction fragmentTransaction = manager.beginTransaction();
              fragmentTransaction.replace(R.id.navContent, fragment).addToBackStack(null).commit();
          }
      });
      displayDefaultFragment();
  }
  
  @Override
  public void onBackPressed() {
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      if (drawer.isDrawerOpen(GravityCompat.START)) {
          drawer.closeDrawer(GravityCompat.START);
      } else {
          super.onBackPressed();
      }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.page__navigation, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
  
      return super.onOptionsItemSelected(item);
  }
  
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
      // Handle navigation view item clicks here.
  
      final int id = item.getItemId();
  
  
      drawer.closeDrawer(GravityCompat.START);
  
      new Handler().postDelayed(new Runnable() {
          @Override
          public void run() {
              switch (id) {
                  case R.id.nav_home:
                      fragment = new Nav_Home();
                      break;
  
                  case R.id.nav_contact:
                      fragment = new Nav_Contact();
                      break;
  
                  case R.id.nav_articles:
                      fragment = new Nav_Article();
                      break;
  
                  case R.id.nav_about:
                      fragment = new Nav_AboutUs();
                      break;
  
                  case R.id.nav_suggest:
                      fragment = new Nav_Suggest();
                      break;
  
                  case R.id.nav_share:
                      fragment = new Nav_Share();
                      break;
  
                  case R.id.nav_rateApp:
                      fragment = new Nav_RateApp();
                      break;
  
  
              }
  
              fragmentManager.beginTransaction()
                      .replace(R.id.navContent, fragment)
                      .addToBackStack(null)
                      .commit();
  
          }
      }, 350);
  
  
      return true;
  }
  
  public void displayDefaultFragment() {
      fragment = new Nav_Home();
      fragmentManager.beginTransaction().replace(R.id.navContent, fragment).commit();
  
  }
  
  public void showSuggestFragment() {
      fragment = new Nav_Profile();
      fragmentManager.beginTransaction().replace(R.id.navContent, fragment).addToBackStack(null).commit();
  }
  
  public void showProfileFragment() {
      fragment = new Nav_Profile();
      fragmentManager.beginTransaction().replace(R.id.navContent, fragment).addToBackStack(null).commit();
  }
  
  public void setFontNavigation() {
      Menu m = navigationView.getMenu();
      for (int i = 0; i &lt; m.size(); i++) {
          MenuItem mi = m.getItem(i);
  
          //for applying a font to subMenu ...
          SubMenu subMenu = mi.getSubMenu();
          if (subMenu != null &amp;&amp; subMenu.size() &gt; 0) {
              for (int j = 0; j &lt; subMenu.size(); j++) {
                  MenuItem subMenuItem = subMenu.getItem(j);
                  SpannableString s = new SpannableString(subMenuItem.getTitle());
                  s.setSpan(new TypefaceSpan("font/mont_regular.ttf"), 0, s.length(),
                          Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                  subMenuItem.setTitle(s);
              }
          }
  
      }
  }
  }
  </code></pre>
  
  <p><strong>First(Default) Fragment of Navigation</strong></p>
  
  <pre><code>public class Nav_Home extends Fragment implements View.OnClickListener{
  
  SharedPreferences mSharedPref;
  
  private SwipeRefreshLayout swipeRefresh_home;
  
  private CardView item_homeTop_coupons, item_homeTop_draws, item_homeTop_event;
  private LinearLayout layout_all_article, layout_all_999;
  private ScrollView shimmer_home;
  
  private List&lt;Model_ListItem&gt; listNewItems;
  private RecyclerView recyclerView_item_home;
  
  private List&lt;Model_Article&gt; articleList;
  private RecyclerView recyclerView_article_home;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
  
      View view = inflater.inflate(R.layout.fragment_nav__home, container, false);
      item_homeTop_coupons = view.findViewById(R.id.item_homeTop_coupons);
      item_homeTop_draws = view.findViewById(R.id.item_homeTop_draws);
      item_homeTop_event = view.findViewById(R.id.item_homeTop_event);
      recyclerView_item_home = view.findViewById(R.id.recyclerView_item_home);
      recyclerView_article_home = view.findViewById(R.id.recyclerView_article_home);
      layout_all_article = view.findViewById(R.id.layout_all_article);
      layout_all_999 = view.findViewById(R.id.layout_all_999);
      swipeRefresh_home = view.findViewById(R.id.swipeRefresh_home);
      shimmer_home = view.findViewById(R.id.shimmer_home);
      item_homeTop_coupons.setOnClickListener(this);
      item_homeTop_draws.setOnClickListener(this);
      item_homeTop_event.setOnClickListener(this);
      layout_all_999.setOnClickListener(this);
      layout_all_article.setOnClickListener(this);
  
      //first settngs
      mSharedPref = PreferenceManager.getDefaultSharedPreferences(view.getContext());
      String session_user_email = mSharedPref.getString("session_user_email","");
  
  
      swipeRefresh_home.setRefreshing(true);
  
      fetchItemsNew();
      fetchArticlesNew();
  
  
      return view;
  }
  
  
  public void openProfileFragment(){
      Fragment fragment;
      FragmentManager fragmentManager = getFragmentManager();
      fragment = new Nav_Profile();
      fragmentManager.beginTransaction().replace(R.id.navContent, fragment).addToBackStack(null).commit();
  }
  
  @Override
  public void onClick(View v) {
      switch (v.getId()){
  
          case R.id.item_homeTop_coupons:
              startActivity(new Intent(getContext(), Page_Coupon.class));
              break;
  
          case R.id.item_homeTop_draws:
              startActivity(new Intent(getContext(), Page_Draw.class));
              break;
  
          case R.id.item_homeTop_event:
              startActivity(new Intent(getContext(), Page_Event.class));
              break;
  
          case R.id.layout_all_999:
              //999 city search activity
              startActivity(new Intent(getContext(), Page_SearchCity.class));
              break;
  
          case R.id.layout_all_article:
              //article fragment
              Fragment fragment;
              FragmentManager fragmentManager = getFragmentManager();
              fragment = new Nav_Article();
              fragmentManager.beginTransaction().replace(R.id.navContent, fragment).addToBackStack(null).commit();
              break;
  
  
      }
  }
  
  public void seeSession(){
  
      //sessions
      mSharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
      String session_user_id = mSharedPref.getString("session_user_id", "");
      String session_user_email = mSharedPref.getString("session_user_email", "");
      String session_user_name = mSharedPref.getString("session_user_name", "");
      String session_user_image = mSharedPref.getString("session_user_image", "");
      String session_user_nickname = mSharedPref.getString("session_user_nickname", "");
  
  
  }
  
  public void fetchItemsNew(){
      listNewItems = new ArrayList&lt;&gt;();
      API_Service api_service = Client.getRetrofitInstance().create(API_Service.class);
      Call&lt;List&lt;Model_ListItem&gt;&gt; call = api_service.fetchItemsNew();
      call.enqueue(new Callback&lt;List&lt;Model_ListItem&gt;&gt;() {
          @Override
          public void onResponse(Call&lt;List&lt;Model_ListItem&gt;&gt; call, Response&lt;List&lt;Model_ListItem&gt;&gt; response) {
  
              if(response.code() == 200){
  
                  listNewItems = response.body();
  
  
                  recyclerView_item_home.setHasFixedSize(true);
                  LinearLayoutManager layoutManager
                          = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
                  recyclerView_item_home.setLayoutManager(layoutManager);
                  Adapter_HomeItem adapter_homeItem = new Adapter_HomeItem(getContext(), listNewItems);
                  recyclerView_item_home.setAdapter(adapter_homeItem);
                  SnapHelper helper = new LinearSnapHelper();
                  helper.attachToRecyclerView(recyclerView_item_home);
  
  
  
              }
  
          }
  
          @Override
          public void onFailure(Call&lt;List&lt;Model_ListItem&gt;&gt; call, Throwable t) {
  
          }
      });
  
  }
  
  public void fetchArticlesNew(){
      articleList = new ArrayList&lt;&gt;();
      API_Service api_service = Client.getRetrofitInstance().create(API_Service.class);
      Call&lt;List&lt;Model_Article&gt;&gt; callArticle = api_service.fetchArticlesNew();
      callArticle.enqueue(new Callback&lt;List&lt;Model_Article&gt;&gt;() {
          @Override
          public void onResponse(Call&lt;List&lt;Model_Article&gt;&gt; call, Response&lt;List&lt;Model_Article&gt;&gt; response) {
  
              if(response.code() == 200){
  
                  articleList = response.body();
  
  
                  recyclerView_article_home.setHasFixedSize(true);
                  LinearLayoutManager layoutManager
                          = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
                  recyclerView_article_home.setLayoutManager(layoutManager);
                  Adapter_HomeArticles adapter_homeArticles = new Adapter_HomeArticles(getContext(), articleList);
                  recyclerView_article_home.setAdapter(adapter_homeArticles);
                  if(swipeRefresh_home.isRefreshing()){
                      swipeRefresh_home.setRefreshing(false);
                  }
                  shimmer_home.setVisibility(View.VISIBLE);
                  swipeRefresh_home.setEnabled(false);
              }
  
          }
  
          @Override
          public void onFailure(Call&lt;List&lt;Model_Article&gt;&gt; call, Throwable t) {
  
          }
      });
  
  }
  }
  </code></pre>
  
  <p><strong>RecyclerView Adapter</strong></p>
  
  <pre><code>public class Adapter_HomeItem extends RecyclerView.Adapter&lt;Adapter_HomeItem.ViewHolder&gt; {
  
  private Context context;
  private List&lt;Model_ListItem&gt; homeList;
  String urlExtension = URL_Extension.url_extension_images;
  
  public Adapter_HomeItem(Context context, List&lt;Model_ListItem&gt; homeList) {
      this.context = context;
      this.homeList = homeList;
  }
  
  @NonNull
  @Override
  public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)     {
  
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_list, parent, false);
      return new ViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
      Glide.with(context).load(urlExtension+homeList.get(position).getItem_image()).into(holder.item_home_image);
      holder.item_home_text.setText(homeList.get(position).getItem_name());
  
      holder.item_home_cardView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              //item detail
              Intent intent = new Intent(context, Page_ItemDetail.class);
              intent.putExtra("itemClicked", ""+homeList.get(position).getItem_id());
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(intent);
          }
      });
  }
  
  @Override
  public int getItemCount() {
      return homeList.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder{
  
      CardView item_home_cardView;
      RoundedImageView item_home_image;
      TextView item_home_text;
  
      public ViewHolder(View itemView) {
          super(itemView);
  
          item_home_text = itemView.findViewById(R.id.item_home_text);
          item_home_image = itemView.findViewById(R.id.item_home_image);
          item_home_cardView = itemView.findViewById(R.id.item_home_cardView);
      }
  }
  
  }
  </code></pre>
  
  <p><strong>Error was here;</strong></p>
  
  <pre><code>public Adapter_HomeArticles.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_article, null);
      int width = parent.getMeasuredWidth()/3;
      view.setLayoutParams(new RecyclerView.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
      return new ViewHolder(view);
  }
  </code></pre>
  
  <p><strong>Throws;</strong></p>
  
  <pre><code>  06-28 17:20:08.543 23120-23120/? E/Zygote: v2
  06-28 17:20:08.543 23120-23120/? E/Zygote: accessInfo : 0
  06-28 17:20:10.468 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
  06-28 17:20:10.473 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
  06-28 17:23:05.018 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:10.423 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:11.108 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:11.628 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:16.288 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:17.533 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:19.008 23120-23120/turkiyedeyapilacak999sey.android E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@7c57e67
  06-28 17:23:19.013 23120-23120/turkiyedeyapilacak999sey.android E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@6446414
      motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@6446414
  06-28 17:23:20.643 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:22.738 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:24.468 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:27.818 23120-23120/turkiyedeyapilacak999sey.android E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  06-28 17:23:28.118 23120-23120/turkiyedeyapilacak999sey.android E/AndroidRuntime: FATAL EXCEPTION: main
      Process: turkiyedeyapilacak999sey.android, PID: 23120
      android.view.InflateException: Binary XML file line #24: Binary XML file line #24: Error inflating class &lt;unknown&gt;
          at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
          at turkiyedeyapilacak999sey.android.Adapter.Adapter_HomeArticles.onCreateViewHolder(Adapter_HomeArticles.java:39)
          at turkiyedeyapilacak999sey.android.Adapter.Adapter_HomeArticles.onCreateViewHolder(Adapter_HomeArticles.java:25)
          at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)
          at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869)
          at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
          at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
          at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)
          at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559)
          at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
          at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
          at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)
          at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
          at android.support.v7.widget.CardView.onMeasure(CardView.java:258)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
          at android.view.View.measure(View.java:20151)
          at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:2104)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
          at android.widget.ScrollView.onMeasure(ScrollView.java:510)
          at android.view.View.measure(View.java:20151)
          at android.support.v4.widget.SwipeRefreshLayout.onMeasure(SwipeRefreshLayout.java:622)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
          at android.view.View.measure(View.java:20151)
          at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1210)
          at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1550)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
          at android.view.View.measure(View.java:20151)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
  </code></pre>