One more way is to use addOnChildAttachStateChangeListener
which handles appearing/disappearing child views in RecyclerView
.
recyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {
@Override
public void onChildViewAttachedToWindow(@NonNull View view) {
forEmptyTextView.setVisibility(View.INVISIBLE);
}
@Override
public void onChildViewDetachedFromWindow(@NonNull View view) {
forEmptyTextView.setVisibility(View.VISIBLE);
}
});