ERROR - VerticalViewPager

T201016

Active Member
Licensed User
Longtime User
Hi!
I have no idea where to look for the error:

B4X:
    public void processAttributeSet(final AttributeSet attributeSet) {
        if (attributeSet == null) return;
        final TypedArray typedArray = mContext.obtainStyledAttributes(
//-------------------------------------------------------------------------------------- E R R O R !
                attributeSet, mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager :
//-------------------------------------------------------------------------------------- E R R O R !
                        R.styleable.HorizontalInfiniteCycleViewPager
        );
        try {
            setMinPageScaleOffset(
                    typedArray.getDimension(
                            mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_min_page_scale_offset :
                                    R.styleable.HorizontalInfiniteCycleViewPager_icvp_min_page_scale_offset,
                            DEFAULT_MIN_PAGE_SCALE_OFFSET
                    )
            );
            setCenterPageScaleOffset(
                    typedArray.getDimension(
                            mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_center_page_scale_offset :
                                    R.styleable.HorizontalInfiniteCycleViewPager_icvp_center_page_scale_offset,
                            DEFAULT_CENTER_PAGE_SCALE_OFFSET
                    )
            );
            setMinPageScale(
                    typedArray.getFloat(
                            mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_min_page_scale :
                                    R.styleable.HorizontalInfiniteCycleViewPager_icvp_min_page_scale,
                            DEFAULT_MIN_SCALE
                    )
            );
            setMaxPageScale(
                    typedArray.getFloat(
                            mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_max_page_scale :
                                    R.styleable.HorizontalInfiniteCycleViewPager_icvp_max_page_scale,
                            DEFAULT_MAX_SCALE
                    )
            );
            setMediumScaled(
                    typedArray.getBoolean(
                            mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_medium_scaled :
                                    R.styleable.HorizontalInfiniteCycleViewPager_icvp_medium_scaled,
                            DEFAULT_IS_MEDIUM_SCALED
                    )
            );
            setScrollDuration(
                    typedArray.getInteger(
                            mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_scroll_duration :
                                    R.styleable.HorizontalInfiniteCycleViewPager_icvp_scroll_duration,
                            DEFAULT_SCROLL_DURATION
                    )
            );

            // Retrieve interpolator
            Interpolator interpolator = null;
            try {
                final int interpolatorId = typedArray.getResourceId(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_interpolator :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_interpolator, 0
                );
                interpolator = interpolatorId == 0 ? null :
                        AnimationUtils.loadInterpolator(mContext, interpolatorId);
            } catch (Resources.NotFoundException exception) {
                interpolator = null;
                exception.printStackTrace();
            } finally {
                setInterpolator(interpolator);
            }
        } finally {
            typedArray.recycle();
        }
    }

---
The folder structure seems to me to be correct. Attribute files are available in the RES directory.

Thank you for any ideas in solving the problem.
 

DonManfred

Expert
Licensed User
Longtime User

T201016

Active Member
Licensed User
Longtime User
The compilation of the project library, there was an error.
How to replace not broadcasting method - obtainStyledAttributes()?
Generating R.java initially, the value of all fixed set were on the: public static int.
I changed the actual value line as below - I don't know whether well?


- Logs:
Starting step: Compiling Java code.
E R R O R: no suitable method found for obtainStyledAttributes(AttributeSet,int)
method Context.obtainStyledAttributes(int,int[]) is not applicable
(argument mismatch; AttributeSet cannot be converted to int)
method Context.obtainStyledAttributes(AttributeSet,int[]) is not applicable
(argument mismatch; int cannot be converted to int[])

B4X:
- Part of the source code:
    ...
    import com.gigamole.infinitecycleviewpager.test.R;

    // Default attributes constants
    private final static float DEFAULT_MIN_SCALE = 0.55F;
    private final static float DEFAULT_MAX_SCALE = 0.8F;
    private final static int DEFAULT_MIN_PAGE_SCALE_OFFSET = 30;
    private final static int DEFAULT_CENTER_PAGE_SCALE_OFFSET = 50;
    private final static boolean DEFAULT_IS_MEDIUM_SCALED = true;
    private final static int DEFAULT_SCROLL_DURATION = 500;

    ...

    public void processAttributeSet(final AttributeSet attributeSet) {
        if (attributeSet == null) return;
        final TypedArray typedArray = mContext.obtainStyledAttributes( //------------- E R R O R!
                attributeSet, mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager :
                        R.styleable.HorizontalInfiniteCycleViewPager
        );
     
        ...

- Figure generated file R.java

B4X:
package com.gigamole.infinitecycleviewpager.test;

import anywheresoftware.b4a.BA;

public class R {
    public static final class styleable {
        public static int VerticalInfiniteCycleViewPager = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager", "styleable", BA.packageName);
        public static int HorizontalInfiniteCycleViewPager = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager", "styleable", BA.packageName);
        public static int VerticalInfiniteCycleViewPager_icvp_min_page_scale_offset = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_min_page_scale_offset", "styleable", BA.packageName);
        public static int HorizontalInfiniteCycleViewPager_icvp_min_page_scale_offset = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_min_page_scale_offset", "styleable", BA.packageName);
        public static int VerticalInfiniteCycleViewPager_icvp_center_page_scale_offset = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_center_page_scale_offset", "styleable", BA.packageName);
        public static int HorizontalInfiniteCycleViewPager_icvp_center_page_scale_offset = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_center_page_scale_offset", "styleable", BA.packageName);
        public static float VerticalInfiniteCycleViewPager_icvp_min_page_scale = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_min_page_scale", "styleable", BA.packageName);
        public static float HorizontalInfiniteCycleViewPager_icvp_min_page_scale = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_min_page_scale", "styleable", BA.packageName);
        public static float VerticalInfiniteCycleViewPager_icvp_max_page_scale = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_max_page_scale", "styleable", BA.packageName);
        public static float HorizontalInfiniteCycleViewPager_icvp_max_page_scale = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_max_page_scale", "styleable", BA.packageName);
        public static boolean VerticalInfiniteCycleViewPager_icvp_medium_scaled = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_medium_scaled", "styleable", BA.packageName);
        public static boolean HorizontalInfiniteCycleViewPager_icvp_medium_scaled = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_medium_scaled", "styleable", BA.packageName);
        public static int VerticalInfiniteCycleViewPager_icvp_scroll_duration = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_scroll_duration", "styleable", BA.packageName);
        public static int HorizontalInfiniteCycleViewPager_icvp_scroll_duration = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_scroll_duration", "styleable", BA.packageName);
        public static int VerticalInfiniteCycleViewPager_icvp_interpolator = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager_icvp_interpolator", "styleable", BA.packageName);
        public static int HorizontalInfiniteCycleViewPager_icvp_interpolator = BA.applicationContext.getResources().getIdentifier("HorizontalInfiniteCycleViewPager_icvp_interpolator", "styleable", BA.packageName);
    }
}
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Follow THE HOLE THREAD r-generator... I have posted the solution how to change the r-file generated with the r-generator.
You need to do similar changes (which you did not as yet)

Some hints:
The line
B4X:
 public static int VerticalInfiniteCycleViewPager = BA.applicationContext.getResources().getIdentifier("VerticalInfiniteCycleViewPager", "styleable", BA.packageName);
must be moved to the last place in the styleable block
Additionally you need to change the definition of the "mainitem"
to
B4X:
 public static int[] VerticalInfiniteCycleViewPager = {};
VerticalInfiniteCycleViewPager_icvp_min_page_scale_offset
and all the other values which belongs to VerticalInfiniteCycleViewPager must be listed inside the mainitem. See the code above. Inside the {} you must list all the properties.
VerticalInfiniteCycleViewPager_* (not using *, you need to add them all commaseparated.

See the r-generator thread
 
Last edited:

T201016

Active Member
Licensed User
Longtime User
Manfred perfectly, I will try to make corrections according to your instructions. Thanks a lot!
 
Top