Declaring a custom android UI element using XML

前端 未结 6 841
渐次进展
渐次进展 2020-11-22 03:43

How do I declare an Android UI element using XML?

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 04:14

    Thanks a lot for the first answer.

    As for me, I had just one problem with it. When inflating my view, i had a bug : java.lang.NoSuchMethodException : MyView(Context, Attributes)

    I resolved it by creating a new constructor :

    public MyView(Context context, AttributeSet attrs) {
         super(context, attrs);
         // some code
    }
    

    Hope this will help !

提交回复
热议问题