Unable to solve incompatible with attribute error in android

后端 未结 2 840
余生分开走
余生分开走 2021-01-27 21:46

I have a following error andI have no clue why this is happening.All I did was add the flag called \"mon\" and tried to add it to the custom view in the xml. flags other than \"

相关标签:
2条回答
  • 2021-01-27 22:12

    You declared the name of property but the type of input is not specified change your attrs to

    <declare-styleable name="MonView">
    <attr name="mon_type" format="flags">
        <flag name="sol" value="0x01"/>
        <flag name="dan" value="0x02"/>
        <flag name="tin" value="0x04"/>
        <flag name="mon" value="0x06"/>
    </attr></declare-styleable>
    

    Hope it helps :)

    0 讨论(0)
  • 2021-01-27 22:12

    I believe, you have a custom view of some kind that uses this attributes, something like MonView. Could you please provide the code of this View as well? It should be either a java or kotlin class. It seems that when you get your attributes on the runtime in your view that utilises them, it will try to map received attribute value to some preset array position or enum type inside you custom view type. Since you've only added the new attribute to the xml, but haven't updated the array (or enum, or just some logic with a switch/case, however it's implemented) you get this error. Hope, this will help. I'll be able to tell you more if there is a right code snippet. Cheers.

    0 讨论(0)
提交回复
热议问题