### Configure BGABanner Data Source (Method 2: View Collection) Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Java code for configuring the BGABanner by directly passing a collection of Views, useful for custom layouts for each guide page. ```java List views = new ArrayList<>(); views.add(View.inflate(context, R.layout.layout_guide_one, null)); views.add(View.inflate(context, R.layout.layout_guide_two, null)); views.add(View.inflate(context, R.layout.layout_guide_three, null)); mContentBanner.setData(views); ``` -------------------------------- ### Configure BGABanner Data Source (Method 3: Image Resource IDs) Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Java code for configuring the BGABanner with image resource IDs, primarily for guide pages that only display images. ```java // Bitmap 的宽高在 maxWidth maxHeight 和 minWidth minHeight 之间 BGALocalImageSize localImageSize = new BGALocalImageSize(720, 1280, 320, 640); // 设置数据源 mContentBanner.setData(localImageSize, ImageView.ScaleType.CENTER_CROP, R.drawable.uoko_guide_background_1, R.drawable.uoko_guide_background_2, R.drawable.uoko_guide_background_3); ``` -------------------------------- ### Configure BGABanner Data Source (Method 1: Data Model and Adapter) Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Java code for configuring the BGABanner with a data model and adapter, suitable for network images and infinite looping with fewer than 3 pages. ```java mContentBanner.setAdapter(new BGABanner.Adapter() { @Override public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) { Glide.with(MainActivity.this) .load(model) .placeholder(R.drawable.holder) .error(R.drawable.holder) .centerCrop() .dontAnimate() .into(itemView); } }); mContentBanner.setData(Arrays.asList("网络图片路径1", "网络图片路径2", "网络图片路径3"), Arrays.asList("提示文字1", "提示文字2", "提示文字3")); ``` -------------------------------- ### 为 Fragment 提供设置 View 的方法 Source: https://github.com/bingoogolapple/bgabanner-android/wiki/设置enterview及skipview 提供一个让使用者主动设置 View 的方法,以解决在 Fragment 中使用时可能遇到的问题。 ```java public void setEnterSkipViewId(View enterView, view skipView) { if (enterView != null) { mEnterView = enterView; } if (skipView != null) { mSkipView = skipView; } } ``` -------------------------------- ### Add Gradle Dependency Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Instructions for adding the BGABanner-Android library to your project's build files. ```groovy implementation 'androidx.legacy:legacy-support-v4:latestVersion' implementation 'com.github.bingoogolapple:BGABanner-Android:latestVersion' ``` -------------------------------- ### Listen for Banner Item Click Events Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Java code for setting a delegate to handle click events on banner items, with built-in protection against repeated clicks. ```java mContentBanner.setDelegate(new BGABanner.Delegate() { @Override public void onBannerItemClick(BGABanner banner, ImageView itemView, String model, int position) { Toast.makeText(banner.getContext(), "点击了" + position, Toast.LENGTH_SHORT).show(); } }); ``` -------------------------------- ### Set Enter and Skip Button IDs and Delegate Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Java code for setting the resource IDs of the 'Enter' and 'Skip' buttons and their click events. The component handles their visibility and click protection. ```java mContentBanner.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() { @Override public void onClickEnterOrSkip() { startActivity(new Intent(GuideActivity.this, MainActivity.class)); finish(); } }); ``` -------------------------------- ### 设置进入按钮和跳过按钮控件资源 id Source: https://github.com/bingoogolapple/bgabanner-android/wiki/设置enterview及skipview 设置进入按钮和跳过按钮控件资源 id,需要开发者自己处理这两个按钮的点击事件。 ```java /** * 设置进入按钮和跳过按钮控件资源 id,需要开发者自己处理这两个按钮的点击事件 * * @param enterResId 进入按钮控件 * @param skipResId 跳过按钮控件 */ public void setEnterSkipViewId(int enterResId, int skipResId) { if (enterResId != 0) { mEnterView = ((Activity) getContext()).findViewById(enterResId); } if (skipResId != 0) { mSkipView = ((Activity) getContext()).findViewById(skipResId); } } ``` -------------------------------- ### BGABanner Custom Attributes Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md Defines the custom attributes for the BGABanner component, allowing for customization of indicator points, auto-play, transition effects, text appearance, placeholder images, and more. ```xml ``` -------------------------------- ### Add BGABanner to Layout Source: https://github.com/bingoogolapple/bgabanner-android/blob/master/README.md XML layout code for including the BGABanner component in your Android application. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.