我的自定义ViewGroup
需要一定数量的字符串用于array
指定的arrays.xml
.
如果不满足该条件,我希望应用程序停止。
对此的最佳做法是什么?
IllegalStateException
我应该从 中抛出一个ViewGroup constructor
吗?
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" );
}