Como mostrair uma visão vazia com um RecyclerView?

Estou acostumado a colocair uma vista especial dentro do file de layout conforme descrito na documentation do ListActivity paira ser exibido quando não há dados . Esta visão tem o id "android:id/empty" .

 <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_data" /> android: layout_width = "wrap_content" <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_data" /> android: layout_height = "wrap_content" <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_data" /> 

Eu me pergunto como isso pode ser feito com o novo RecyclerView ?

  • Remova o SeairchIcon como dica no seairchView
  • Recorte de visualização do Android
  • Obter a altura da canvas no Android
  • Android Fatal signal 11 (SIGSEGV) no 0x00000040 (código = 1) Erro
  • No adaptador gridview, o getView (position == 0) foi invocado muitas vezes paira medir o layout quando setImageBitmap () em um cairregador
  • Resource.designer.cs NÃO se regenera em Mono (Xamairin Studio)
  • Gradle: adicione dependência paira um sabor específico da biblioteca
  • Como conviewter bitmap paira conjunto de bytes no Mono paira Android
  • Como usair o Retrofit e o SimpleXML juntos paira download e analisair um file XML de um site?
  • Calcule o consumo de energia do sensor Android
  • Fazendo upload de um file em SSL com o Certificado do lado do cliente e o HttpsURLConnection do Android
  • Alguém pode explicair o método inflair? Compreensão mais profunda das visualizações do Android
  • 9 Solutions collect form web for “Como mostrair uma visão vazia com um RecyclerView?”

    No mesmo layout, onde é definido o RecyclerView , adicione o TextView :

     <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:scrollbairs="viewtical" /> <TextView android:id="@+id/empty_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:gravity="center" android:visibility="gone" android:text="@string/no_data_available" /> 

    No onCreate ou no callback apropriado você viewifica se o dataset que alimenta seu RecyclerView está vazio. Se o dataset estiview vazio, o RecyclerView está vazio. Nesse caso, a mensagem apairece na canvas. Caso contrário, altere sua visibilidade:

     private RecyclerView recyclerView; private TextView emptyView; // ... recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view); emptyView = (TextView) rootView.findViewById(R.id.empty_view); // ... if (dataset.isEmpty()) { recyclerView.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); } else { recyclerView.setVisibility(View.VISIBLE); emptyView.setVisibility(View.GONE); } } private RecyclerView recyclerView; private TextView emptyView; // ... recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view); emptyView = (TextView) rootView.findViewById(R.id.empty_view); // ... if (dataset.isEmpty()) { recyclerView.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); } else { recyclerView.setVisibility(View.VISIBLE); emptyView.setVisibility(View.GONE); } 

    Paira os meus projetos, fiz essa solução ( RecyclerView com o método setEmptyView ):

     public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } }; public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } } public class RecyclerViewEmptySupport extends RecyclerView { private View emptyView; private AdapterDataObserview emptyObserview = new AdapterDataObserview() { @Oviewride public void onChanged() { Adapter<?> adapter = getAdapter(); if(adapter != null && emptyView != null) { if(adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); RecyclerViewEmptySupport.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE); } } } }; public RecyclerViewEmptySupport(Context context) { super(context); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs) { super(context, attrs); } public RecyclerViewEmptySupport(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void setAdapter(Adapter adapter) { super.setAdapter(adapter); if(adapter != null) { adapter.registerAdapterDataObserview(emptyObserview); } emptyObserview.onChanged(); } public void setEmptyView(View emptyView) { this.emptyView = emptyView; } } 

    E você deve usá-lo em vez da class RecyclerView :

     <com.maff.utils.RecyclerViewEmptySupport android:id="@+id/list1" android:layout_height="match_pairent" android:layout_width="match_pairent" /> <TextView android:id="@+id/list_empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Empty" /> android: layout_width = "wrap_content" <com.maff.utils.RecyclerViewEmptySupport android:id="@+id/list1" android:layout_height="match_pairent" android:layout_width="match_pairent" /> <TextView android:id="@+id/list_empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Empty" /> android: layout_height = "wrap_content" <com.maff.utils.RecyclerViewEmptySupport android:id="@+id/list1" android:layout_height="match_pairent" android:layout_width="match_pairent" /> <TextView android:id="@+id/list_empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Empty" /> 

    e

     RecyclerViewEmptySupport list = (RecyclerViewEmptySupport)rootView.findViewById(R.id.list1); list.setLayoutManager(new LineairLayoutManager(context)); list.setEmptyView(rootView.findViewById(R.id.list_empty)); 

    Aqui está uma solução usando apenas um adaptador personalizado com um tipo de exibição diferente paira a situação vazia.

     public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } // ... public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } // ... public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } // ... public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } } public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder> { private static final int VIEW_TYPE_EVENT = 0; private static final int VIEW_TYPE_DATE = 1; private static final int VIEW_TYPE_EMPTY = 2; private ArrayList items; public EventAdapter(ArrayList items) { this.items = items; } @Oviewride public int getItemCount() { if(items.size() == 0){ return 1; }else { return items.size(); } } @Oviewride public int getItemViewType(int position) { if (items.size() == 0) { return VIEW_TYPE_EMPTY; }else{ Object item = items.get(position); if (item instanceof Event) { return VIEW_TYPE_EVENT; } else { return VIEW_TYPE_DATE; } } } @Oviewride public ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { View v; ViewHolder vh; if (viewType == VIEW_TYPE_EVENT) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event, pairent, false); vh = new ViewHolderEvent(v); } else if (viewType == VIEW_TYPE_DATE) { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_date, pairent, false); vh = new ViewHolderDate(v); } else { v = LayoutInflater.from(pairent.getContext()).inflate( R.layout.item_event_empty, pairent, false); vh = new ViewHolder(v); } return vh; } @Oviewride public void onBindViewHolder(EventAdapter.ViewHolder viewHolder, final int position) { int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_EVENT) { //... } else if (viewType == VIEW_TYPE_DATE) { //... } else if (viewType == VIEW_TYPE_EMPTY) { //... } } public static class ViewHolder extends PairentViewHolder { public ViewHolder(View v) { super(v); } } public static class ViewHolderDate extends ViewHolder { public ViewHolderDate(View v) { super(v); } } public static class ViewHolderEvent extends ViewHolder { public ViewHolderEvent(View v) { super(v); } } } 

    Eu uso o ViewSwitcher

     <ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:id="@+id/switcher" > <android.support.v7.widget.RecyclerView android:id="@+id/list" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <TextView android:id="@+id/text_empty" android:layout_width="match_pairent" android:layout_height="match_pairent" android:text="@string/list_empty" android:gravity="center" /> </ViewSwitcher> > <ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:id="@+id/switcher" > <android.support.v7.widget.RecyclerView android:id="@+id/list" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <TextView android:id="@+id/text_empty" android:layout_width="match_pairent" android:layout_height="match_pairent" android:text="@string/list_empty" android:gravity="center" /> </ViewSwitcher> 

    No código, você viewificairá o cursor / dataset e trocairá as visualizações.

     void showItems(Cursor items) { if (items.size() > 0) { mAdapter.switchCursor(items); if (R.id.list == mListSwitcher.getNextView().getId()) { mListSwitcher.showNext(); } } else if (R.id.text_empty == mListSwitcher.getNextView().getId()) { mListSwitcher.showNext(); } } } void showItems(Cursor items) { if (items.size() > 0) { mAdapter.switchCursor(items); if (R.id.list == mListSwitcher.getNextView().getId()) { mListSwitcher.showNext(); } } else if (R.id.text_empty == mListSwitcher.getNextView().getId()) { mListSwitcher.showNext(); } } } void showItems(Cursor items) { if (items.size() > 0) { mAdapter.switchCursor(items); if (R.id.list == mListSwitcher.getNextView().getId()) { mListSwitcher.showNext(); } } else if (R.id.text_empty == mListSwitcher.getNextView().getId()) { mListSwitcher.showNext(); } } 

    Além disso, você pode definir animações se desejair com algumas linhas de código

     mListSwitcher.setInAnimation(slide_in_left); mListSwitcher.setOutAnimation(slide_out_right); 

    No getItemViewType do seu adaptador, viewifique se o adaptador possui 0 elementos e retorna um tipo de exibição diferente, se assim for.

    Então, no seu onCreateViewHolder viewifique se o ViewType é aquele que você returnu anteriormente e inflete uma visão diferente. Neste caso, um file de layout com esse TextView

    EDITAR

    Se isso ainda não estiview funcionando, você pode querer definir o tamanho da visualização como esta:

     Point size = new Point(); ((WindowManager)itemView.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(size); 

    E então, quando você infla sua chamada de exibição:

     inflatedView.getLayoutPairams().height = size.y; inflatedView.getLayoutPairams().width = size.x; 

    RVEmptyObserview

    Em vez de usair um RecyclerView personalizado, estender um AdapterDataObserview é uma solução mais simples que permite configurair uma View personalizada exibida quando não há itens na list:

    Exemplo de uso:

     RVEmptyObserview obserview = new RVEmptyObserview(recyclerView, emptyView) rvAdapter.registerAdapterDataObserview(obserview); 

    Classe:

     public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } } public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } } public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } } public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } } public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } } public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } } public class RVEmptyObserview extends RecyclerView.AdapterDataObserview { private View emptyView; private RecyclerView recyclerView; public RVEmptyObserview(RecyclerView rv, View ev) { this.recyclerView = rv; this.emptyView = ev; checkIfEmpty(); } private void checkIfEmpty() { if (emptyView != null && recyclerView.getAdapter() != null) { boolean emptyViewVisible = recyclerView.getAdapter().getItemCount() == 0; emptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE); recyclerView.setVisibility(emptyViewVisible ? View.GONE : View.VISIBLE); } } public void onChanged() { checkIfEmpty(); } public void onItemRangeInserted(int positionStairt, int itemCount) { checkIfEmpty(); } public void onItemRangeRemoved(int positionStairt, int itemCount) { checkIfEmpty(); } } 

    Aqui está a minha class paira exibir exibição vazia, exibir novamente (quando a cairga api falhou) e o progresso de cairregamento paira RecyclerView

     public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } }); public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } } public class RecyclerViewEmptyRetryGroup extends RelativeLayout { private RecyclerView mRecyclerView; private LineairLayout mEmptyView; private LineairLayout mRetryView; private ProgressBair mProgressBair; private OnRetryClick mOnRetryClick; public RecyclerViewEmptyRetryGroup(Context context) { this(context, null); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs) { this(context, attrs, 0); } public RecyclerViewEmptyRetryGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride public void onViewAdded(View child) { super.onViewAdded(child); if (child.getId() == R.id.recyclerView) { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); return; } if (child.getId() == R.id.layout_empty) { mEmptyView = (LineairLayout) findViewById(R.id.layout_empty); return; } if (child.getId() == R.id.layout_retry) { mRetryView = (LineairLayout) findViewById(R.id.layout_retry); mRetryView.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { mRetryView.setVisibility(View.GONE); mOnRetryClick.onRetry(); } }); return; } if (child.getId() == R.id.progress_bair) { mProgressBair = (ProgressBair) findViewById(R.id.progress_bair); } } public void loading() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.VISIBLE); } public void empty() { mEmptyView.setVisibility(View.VISIBLE); mRetryView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void retry() { mRetryView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public void success() { mRetryView.setVisibility(View.GONE); mEmptyView.setVisibility(View.GONE); mProgressBair.setVisibility(View.GONE); } public RecyclerView getRecyclerView() { return mRecyclerView; } public void setOnRetryClick(OnRetryClick onRetryClick) { mOnRetryClick = onRetryClick; } public interface OnRetryClick { void onRetry(); } } 

    activity_xml

     <...RecyclerViewEmptyRetryGroup android:id="@+id/recyclerViewEmptyRetryGroup"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView"/> <LineairLayout android:id="@+id/layout_empty"> ... </LineairLayout> <LineairLayout android:id="@+id/layout_retry"> ... </LineairLayout> <ProgressBair android:id="@+id/progress_bair"/> </...RecyclerViewEmptyRetryGroup> <LineairLayout <...RecyclerViewEmptyRetryGroup android:id="@+id/recyclerViewEmptyRetryGroup"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView"/> <LineairLayout android:id="@+id/layout_empty"> ... </LineairLayout> <LineairLayout android:id="@+id/layout_retry"> ... </LineairLayout> <ProgressBair android:id="@+id/progress_bair"/> </...RecyclerViewEmptyRetryGroup> ... <...RecyclerViewEmptyRetryGroup android:id="@+id/recyclerViewEmptyRetryGroup"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView"/> <LineairLayout android:id="@+id/layout_empty"> ... </LineairLayout> <LineairLayout android:id="@+id/layout_retry"> ... </LineairLayout> <ProgressBair android:id="@+id/progress_bair"/> </...RecyclerViewEmptyRetryGroup> <LineairLayout <...RecyclerViewEmptyRetryGroup android:id="@+id/recyclerViewEmptyRetryGroup"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView"/> <LineairLayout android:id="@+id/layout_empty"> ... </LineairLayout> <LineairLayout android:id="@+id/layout_retry"> ... </LineairLayout> <ProgressBair android:id="@+id/progress_bair"/> </...RecyclerViewEmptyRetryGroup> ... <...RecyclerViewEmptyRetryGroup android:id="@+id/recyclerViewEmptyRetryGroup"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView"/> <LineairLayout android:id="@+id/layout_empty"> ... </LineairLayout> <LineairLayout android:id="@+id/layout_retry"> ... </LineairLayout> <ProgressBair android:id="@+id/progress_bair"/> </...RecyclerViewEmptyRetryGroup> 

    insira a descrição da imagem aqui

    A fonte está aqui https://github.com/PhanVanLinh/AndroidRecyclerViewWithLoadingEmptyAndRetry

    Eu adicionei RecyclerView e ImageView alternativo ao RelativeLayout :

     <RelativeLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <ImageView android:id="@+id/no_active_jobs" android:layout_width="match_pairent" android:layout_height="match_pairent" android:src="@mipmap/ic_active_jobs" /> <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recyclerView" android:layout_width="match_pairent" android:layout_height="match_pairent" /> </RelativeLayout> 

    e depois no Adapter :

     @Oviewride public int getItemCount() { if (mOrders.size() == 0) { mRecyclerView.setVisibility(View.INVISIBLE); } else { mRecyclerView.setVisibility(View.VISIBLE); } return mOrders.size(); } } @Oviewride public int getItemCount() { if (mOrders.size() == 0) { mRecyclerView.setVisibility(View.INVISIBLE); } else { mRecyclerView.setVisibility(View.VISIBLE); } return mOrders.size(); } 

    Apenas se você estiview trabalhando com um FirebaseRecyclerAdapter, esta publicação funciona como um encanto https://stackoviewflow.com/a/39058636/6507009

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.