0
我的自定义ViewGroup
需要arrays.xml
中指定的array
的一定数量的字符串。如果条件不符合,则中止ViewGroup?
我希望应用程序停止,如果不满足条件。
这是什么最佳做法?
我应该只是从ViewGroup constructor
扔IllegalStateException
?
public MyViewGroup(Context context, AttributeSet attrs)
{
super(context, attrs);
if(getResources().getStringArray(R.array.carousellabels).length != 7)
throw new IllegalStateException("There must exactly 7 items for
array resource R.array.carousellabels");
}