How to show and hide the view in recycler view in Android?

In my application, I use recycler view. I want to show and hide the view by a certain condition. But when I look at recycler views, I do not expect to look. When I see a view, it becomes visible to other lines, and also by accident, I understand that when it processes the re-presentation, and when the previous view, when it is processed, finds the visibility of this view. How can I hide the idea of ​​a particular condition? here is my adapter code

  @Override
public void onBindViewHolder(UrduRhymesViewHolder holder, int position) {
    RhymesModel current = mUrduRhymesList.get(position);
    AppUtility.setCustomFont(mContext, holder.tvUrduRhymesName, Constants.HANDLEE_REGULAR);
    holder.tvUrduRhymesName.setText(current.getRhymeName());
    holder.ivUrduRhymesLogo.setImageUrl(current.getThumbnailUrl(), mImageRequest);
    int status = AppUtility.getFavouriteStatus(mContext, current.getRhymeName(), new UrduRhymesDb(mContext));
    if (status == 0)
        holder.btnFavourite.setBackgroundResource(R.mipmap.btn_star_unactive);
    else
        holder.btnFavourite.setBackgroundResource(R.mipmap.btn_star);

    ProgressbarDetails progressbarDetails = ProgressbarDetails.getProgressDetail(current.getRhymeName());
    if (progressbarDetails == null) {
        progressbarDetails = new ProgressbarDetails();
        progressbarDetails.prgProgressBar = holder.pbRhymeDownload;
        progressbarDetails.download_btn_settings = holder.downloadButtonLayout;
    } else {
        progressbarDetails.prgProgressBar = holder.pbRhymeDownload;
        progressbarDetails.download_btn_settings = holder.downloadButtonLayout;
        holder.pbRhymeDownload.setProgress(progressbarDetails.progress);
    }

    ProgressbarDetails.addUpdateProgressDetail(current.getRhymeName(), progressbarDetails);

    if (progressbarDetails != null && progressbarDetails.isDownloading) {
        Log.e("test","downloading foe position "+position );
        holder.downloadButtonLayout.setBackgroundResource(R.mipmap.btn_download);
        holder.pbRhymeDownload.setVisibility(View.VISIBLE);
        holder.pbRhymeDownload.setProgress(progressbarDetails.progress);
    } else {
        Log.e("test","should not be visible for position "+position);
        holder.pbRhymeDownload.setVisibility(View.GONE);

    }
}

Here progressbarDetails.isDownloading (true) is the criteria when I want to show my view, but this is an else condition, it does not hide my view

: ProgressbarDetails (Singleton) - , .

+4
3

recylerview.

: , recycliewiew ArrayList arraylist (temp_list)

:

: , . temp_list. notifyDataSetChanged()

: temp_list , . . notifyDataSetChanged()

+4

viewHolder, , . onBindViewHolder.

recyclerView , - viewHolder.

+1

Does it really mean when your data was changed? and you want to change your layout?

adapter.notifyDataSetChanged();
0
source

Source: https://habr.com/ru/post/1623043/


All Articles