I have a extended class, in class have a var, I define this by value, but say this is null !!!!
public class CalendarCell extends TextView
{
public static final String TAG = "CalendarCell";
protected ArrayList<Integer> cellStates = new ArrayList<>();
public CalendarCell(Context context)
{
super(context);
}
public CalendarCell(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public CalendarCell(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
@Override
protected int[] onCreateDrawableState(int states)
{
int newStatesSize = cellStates.size(); // Error here (null)
if (newStatesSize > 0)
{
...
}
else
{
return super.onCreateDrawableState(states);
}
}
public void resetStates()
{
cellStates.clear();
}
public void addState(int state)
{
if(!cellStates.contains(state))
cellStates.add(state);
}
}
I defined 'cellStates' by value.but say this is null. Why???
java.lang.NullPointerException
at yaran.CalendarSection.ViewSection.CalendarCell.onCreateDrawableState(CalendarCell.java:44)