 
                        如图,第一次用自定义继承listview的写法,不是很理解,之前都用布局用的。如何理解这个三个方法,一定要写全吗?

public class DefineListView extends ListView {
    public DefineListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    public DefineListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public DefineListView(Context context) {
        super(context);
    }
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在java代码中直接new一个DefineListView ,会调用一个参数的构造函数,比如
DefineListView defineListView = new DefineListView (context)。如果是在xml中创建这个控件并且没有指定style,会调用两个参数的,如
如果在xml中创建并设置了style,就会调用三个参数的。