androi自定义问题总结

android.view.InflateException

自定义view时候出现了该异常问题

构造函数问题

    自定义一个View,派生实现基类View的三个构造函数

    View(Context context)     //Simple constructor to use when creating a view from code

    View(Context context, AttributeSet attrs)     //Constructor that is called when inflating a view from XML

    View(Context context, AttributeSet attrs, int defStyle)     //Perform inflation from XML and apply a class-specific base style

    从文档上的介绍来看,第二个和第三个构造函数对于XML这种引用方式是必须实现的,这三个构造函数应该是在不同的应用场合来实例化

    一个View对象。


你可能感兴趣的:(android)