[AndroidStudio problem record] Error: Found item xxx more than one time solution

【question】

The isHardwareAccel attribute is defined in the res/values/atts.xml file. The operation produces Error: Found item Attr/tabTextSize more than one time, which means error: found that the item attr/isHardwareAccel is defined more than once.

    public HdrPictureSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
        try (TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.HdrPictureSurfaceView)) {
            mIsHardwareAccel = attributes.getBoolean(R.styleable.HdrPictureSurfaceView_isHardwareAccel, false);
        }

        init();
    }
<resources>
    <declare-styleable name="ImageSurfaceView">
        <attr name="isHardwareAccel" format="boolean"/>
    </declare-styleable>
    <declare-styleable name="HdrPictureSurfaceView">
        <attr name="isHardwareAccel" format="boolean"/>
    </declare-styleable>
</resources>

【reason】

Repeat the definition of the isHardwareAccel attribute, extract <attr name="isHardwareAccel" format="boolean"/>, and then call it in each View. Change as follows:

<resources>
    <attr name="isHardwareAccel" format="boolean"/>
    <declare-styleable name="ImageSurfaceView">
        <attr name="isHardwareAccel"/>
    </declare-styleable>
    <declare-styleable name="HdrPictureSurfaceView">
        <attr name="isHardwareAccel"/>
    </declare-styleable>
</resources>

Guess you like

Origin blog.csdn.net/cocoduco/article/details/130294000