• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps getSelectedItem() crashed Android, please help

pascal88

Lurker
Hey,
the following lines crash android with a NPE:

Spinner spinner = (Spinner) findViewById(R.id.type);

Object type = spinner.getSelectedItem();

I checked the id for correct spelling in the xml.
The spinner is being populated in the first activity, after a button is pressed a new activity is opened corresponding to the class containing the above code.

Please Help
Pascal
 
Well, Android does not find the view corresponding to that id. But it's indeed impossible to help you without seeing the layout xml and the activity src (at least the relevant part).
 
Back
Top Bottom