@Override public final int getLayout(int index, int type) { TabBase Tab = getItem(index); if (type == TYPE_NO_CONTENT) return mLayoutNoContent; else if (type == TYPE_HEADER) return R.layout.list_item_header; int layout = Tab.getLayout(); if (layout <= 0) { // If no layout was specified for the individual Tab, use the adapter's set layout layout = mLayout; } return layout; }
@Override public final int getItemViewType(int position) { TabBase item = getItem(position); if (item.getLayout() > 0) { if (mViewTypes.containsKey(item.getLayout())) return mViewTypes.get(item.getLayout()); else if (mLayout == item.getLayout()) return TYPE_REGULAR; else if (mLayoutNoContent == item.getLayout()) return TYPE_NO_CONTENT; else if (mLayoutHeader == item.getLayout()) return TYPE_HEADER; String name = getContext().getResources().getResourceName(item.getLayout()); throw new RuntimeException("The layout " + name + " is not registered."); } else { if (item.isHeader()) return TYPE_HEADER; else if ((item.getContent() == null || item.getContent().trim().isEmpty())) return TYPE_NO_CONTENT; else return TYPE_REGULAR; } }