Cleveroad / AdaptiveTableLayout

Library that makes it possible to read, edit and write CSV files
MIT License
1.9k stars 234 forks source link

if set visible or gone, have some question #17

Closed a584327136 closed 7 years ago

a584327136 commented 7 years ago

image

a584327136 commented 7 years ago

My English is not very good, I'm sorry. I ran into a problem with the project, and if I set up the data on the slide screen some views are lost. In order to get back to the problem, I took the source of the project and hid all of the views, and I just showed this view in a specific location, for example, when the columns were all three, and then there was a problem. Once again, the view shows that the view disappears once again. This question has been bothering me for a long time. Please see if you can solve it. Thank you

a584327136 commented 7 years ago

@Override public void onBindViewHolder(@NonNull ViewHolderImpl viewHolder, int row, int column) { final TestViewHolder vh = (TestViewHolder) viewHolder; String itemData = mTableDataSource.getItemData(row, column); // skip headers

    if (TextUtils.isEmpty(itemData)) {
        itemData = "";
    }

    itemData = itemData.trim();
    vh.tvText.setVisibility(View.GONE);
    vh.ivImage.setVisibility(View.GONE);
    vh.tvText.setText(itemData);
    Glide.with(vh.ivImage.getContext())
            .load(itemData)
            .fitCenter()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .listener(new RequestListener<String, GlideDrawable>() {
                @Override
                public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                    vh.ivImage.setVisibility(View.GONE);
                    vh.tvText.setVisibility(View.GONE);
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    vh.ivImage.setVisibility(View.GONE);
                    vh.tvText.setVisibility(View.GONE);
                    return false;
                }
            })
            .into(vh.ivImage);
    if (row == 3 && column == 3) {
        vh.tvText.setVisibility(View.VISIBLE);
        vh.ivImage.setVisibility(View.VISIBLE);
    }
}
a584327136 commented 7 years ago

The screenshots are not complete, so I'll stick with the code

tu2460 commented 7 years ago

@a584327136 使用INVISIBLE不要使用GONE

a584327136 commented 7 years ago

我找到问题了, @tu2460