我穿過所有給定的構造樣式參考:如何在不使用樣式屬性的情況下設置自定義視圖的樣式?
public MyCustomView(Context context)
{
super(context, null, R.style.MyStyle);
}
public MyCustomView(Context context, AttributeSet attrs)
{
super(context, attrs, R.style.MyStyle);
}
public MyCustomView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, R.style.MyStyle);
}
我的棉花糖嘗試此。樣式不適用,但在通過樣式屬性應用時起作用。
據我所知,有4個不是3視圖的構造函數 – Selvin
是不是假設是'super'而不是'this' –