Search in sources :

Example 1 with ImageNetAdapter

use of com.test.banner.adapter.ImageNetAdapter in project banner by youth5201314.

the class BannerFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    banner.setAdapter(new ImageNetAdapter(DataBean.getTestData3()));
    banner.setIndicator(new RectangleIndicator(getActivity()));
    banner.setIndicatorSpace((int) BannerUtils.dp2px(4));
    banner.setIndicatorRadius(0);
}
Also used : ImageNetAdapter(com.test.banner.adapter.ImageNetAdapter) RectangleIndicator(com.youth.banner.indicator.RectangleIndicator)

Example 2 with ImageNetAdapter

use of com.test.banner.adapter.ImageNetAdapter in project banner by youth5201314.

the class BlankFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LinearLayout linearLayout = getView().findViewById(R.id.ll_view);
    // 通过new的方式创建banner
    Banner banner = new Banner(getActivity());
    banner.setAdapter(new ImageNetAdapter(DataBean.getTestData3()));
    banner.addBannerLifecycleObserver(this);
    banner.setIndicator(new CircleIndicator(getActivity()));
    // 将banner加入到父容器中,实际使用不一定一样
    linearLayout.addView(banner, LinearLayout.LayoutParams.MATCH_PARENT, (int) BannerUtils.dp2px(120));
}
Also used : Banner(com.youth.banner.Banner) CircleIndicator(com.youth.banner.indicator.CircleIndicator) ImageNetAdapter(com.test.banner.adapter.ImageNetAdapter) LinearLayout(android.widget.LinearLayout)

Aggregations

ImageNetAdapter (com.test.banner.adapter.ImageNetAdapter)2 LinearLayout (android.widget.LinearLayout)1 Banner (com.youth.banner.Banner)1 CircleIndicator (com.youth.banner.indicator.CircleIndicator)1 RectangleIndicator (com.youth.banner.indicator.RectangleIndicator)1