0

I'm trying to understand what i missed. I have the implementation of SwipeLayout class with the next lines inside constructor:

public SwipeLayout(Context context, AttributeSet attrs, int defStyle) {
    ...
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeLayout);
    int dragEdgeChoices = a.getInt(R.styleable.SwipeLayout_drag_edge, DRAG_RIGHT);
    mEdgeSwipesOffset[DragEdge.Left.ordinal()] = a.getDimension(R.styleable.SwipeLayout_leftEdgeSwipeOffset, 0);
    mEdgeSwipesOffset[DragEdge.Right.ordinal()] = a.getDimension(R.styleable.SwipeLayout_rightEdgeSwipeOffset, 0);
    mEdgeSwipesOffset[DragEdge.Top.ordinal()] = a.getDimension(R.styleable.SwipeLayout_topEdgeSwipeOffset, 0);
    mEdgeSwipesOffset[DragEdge.Bottom.ordinal()] = a.getDimension(R.styleable.SwipeLayout_bottomEdgeSwipeOffset, 0);
    setClickToClose(a.getBoolean(R.styleable.SwipeLayout_clickToClose, mClickToClose));
    ...
}

and have an attr.xml file with styleable values:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeLayout">
    <attr name="drag_edge">
        <flag name="left" value="1" />
        <flag name="right" value="2" />
        <flag name="top" value="4" />
        <flag name="bottom" value="8" />
    </attr>
    <attr name="leftEdgeSwipeOffset" format="dimension" />
    <attr name="rightEdgeSwipeOffset" format="dimension" />
    <attr name="topEdgeSwipeOffset" format="dimension" />
    <attr name="bottomEdgeSwipeOffset" format="dimension" />
    <attr name="show_mode" format="enum">
        <enum name="lay_down" value="0" />
        <enum name="pull_out" value="1" />
    </attr>
    <attr name="clickToClose" format="boolean" />
</declare-styleable>
</resources>

But it is an error inside xml that tells me that names like "drag_edge", "leftEdgeSwipeOffset", "rightEdgeSwipeOffset" and others are not found. Maybe I have missed some support or design libraries?

Eugene V.
  • 90
  • 11
  • Which folder is your `attr.xml` file in? – Mike M. May 13 '20 at 02:37
  • @MikeM. I located it inside 'values' folder – Eugene V. May 13 '20 at 07:57
  • Well, that's the right spot. I'm not sure if I'm understanding your description correctly. Do you mean that the errors are showing in the `attr.xml` file itself? Or do you mean that those names aren't found when you try to use them in the Java code? – Mike M. May 13 '20 at 08:01
  • @MikeM. Yeap, I have a red highlited attribute names like "drag_edge", "leftEdgeSwipeOffset" and other parameters inside xml file. And if I try to start typing attr name inside quotes I see the suggested variants list with different names but not that I need :L – Eugene V. May 13 '20 at 11:19
  • Just to be clear, that's under `src/main/res/values/`, yeah? If so, try cleaning/rebuilding your project (under the Build menu), and if that doesn't fix it, try Invalidate Caches/Restart (under File). I copied/pasted your XML into a project, and it's perfectly valid, so those are about the only things that I can think of, atm. – Mike M. May 13 '20 at 11:26
  • Hmm, okay, I will try it, thanks for help :) – Eugene V. May 13 '20 at 11:42

0 Answers0