You need to initialize all View
s after calling setContentView()
so your NumberPicker
is null
. Change your initialization of
private NumberPicker np = (NumberPicker) findViewById(R.id.btnGetMonthFromSpinner);
to
NumberPicker np;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// here or anywhere after here
np = (NumberPicker) findViewById(R.id.btnGetMonthFromSpinner);
loadDisplay();
}
Though, you initialize another picker with the same name in loadDisplay()
. Not sure if you meant to do that.