scrolling/selecting 号码时,号码选择器抛出错误

Number picker throws up error while scrolling/selecting number

这是我的号码选择器代码 activity,其中包含一个文本视图,设置为在选择号码时更改。但每当我尝试滚动时,应用程序就会崩溃。

    protected void onCreate(Bundle savedInstanceState) {
    final TextView numberis = (TextView) findViewById(R.id.numberis);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ageratio);
    NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
    assert numberPicker != null;
    numberPicker.setWrapSelectorWheel(true);
    numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    numberPicker.setMinValue(0);
    numberPicker.setMaxValue(12);
    numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {

            numberis.setText("Selected number is "+
                    newVal);
        }
    });

这是我的 xml 文件。

    <NumberPicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/numberPicker"
    android:layout_gravity="center_horizontal" />

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    </LinearLayout>

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:text="Select a number"
    android:layout_marginLeft="131dp"
    android:id="@+id/numberis"
    />

在声明 TextView 编号的地方写下行

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ageratio);
final TextView numberis = (TextView) findViewById(R.id.numberis);