【发布时间】:2009-10-07 08:32:25
【问题描述】:
我的自定义ViewGroup 期望array 在arrays.xml 中指定一定数量的字符串。
如果不满足该条件,我希望应用停止。
这方面的最佳做法是什么?
我应该从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" );
}
【问题讨论】:
标签: java android mobile android-widget