Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在刷新的时候,Indicator 不刷新 #8

Open
XiaoMaGe258 opened this issue Jul 21, 2017 · 2 comments
Open

在刷新的时候,Indicator 不刷新 #8

XiaoMaGe258 opened this issue Jul 21, 2017 · 2 comments

Comments

@XiaoMaGe258
Copy link

我在Fragment里,网络获取bannerList列表:
第一次,bannerList有两个,setRvBannerData(bannerList);后,有两个圆点。
第二次,bannerList有1个,setRvBannerData(bannerList);后,还是有两个圆点,没有刷新。
能留一个刷新方法么?

@XiaoMaGe258
Copy link
Author

补充:从1个变成2个,会刷新出来。 但是从2个变成1个,没有刷新。

求帮助!

@XiaoMaGe258
Copy link
Author

这是我根据demo改的。请帮忙看下应该怎么改,感谢!非常感谢!
public class MainActivity extends AppCompatActivity {
List banners = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button btn = (Button) findViewById(R.id.btn_update);

    final RecyclerViewBanner recyclerViewBanner2 = (RecyclerViewBanner) findViewById(R.id.rv_banner_2);

    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            set1();
            recyclerViewBanner2.setRvBannerData(banners);
        }
    });

    banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487221110004&di=d6043e4b0c90ddf3ea5096c3d8eb8f58&imgtype=0&src=http%3A%2F%2Fimage.tianjimedia.com%2FuploadImages%2F2014%2F067%2F5116EPAUD762_1000x500.jpg"));
    banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1490438881557&di=e61065ccc8d7b44591e1c4ba8df672ee&imgtype=0&src=http%3A%2F%2Fc.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2F18d8bc3eb13533fa00428309a0d3fd1f41345b24.jpg"));
    banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1491018668060&di=b96bf4ac065ab547eddc5af24dfbedd5&imgtype=0&src=http%3A%2F%2Fi2.sanwen8.cn%2Fdoc%2F1610%2F704-161024211H3.jpg"));
    recyclerViewBanner2.setRvBannerData(banners);
    recyclerViewBanner2.setOnSwitchRvBannerListener(new RecyclerViewBanner.OnSwitchRvBannerListener() {
        @Override
        public void switchBanner(int position, AppCompatImageView bannerView) {
            Glide.with(bannerView.getContext())
                    .load(banners.get(position).getUrl())
                    .placeholder(R.mipmap.ic_launcher)
                    .into(bannerView);
        }
    });
}

private void set1(){
    banners.clear();
    banners.add(new Banner("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487221110004&di=d6043e4b0c90ddf3ea5096c3d8eb8f58&imgtype=0&src=http%3A%2F%2Fimage.tianjimedia.com%2FuploadImages%2F2014%2F067%2F5116EPAUD762_1000x500.jpg"));
}

private class Banner {
    String url;
    public Banner(String url) {
        this.url = url;
    }
    public String getUrl() {
        return url;
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant