Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Spinner gets a null-value.

 
Sven Sylta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why my spinnner is causing a nullpointerexception. Row 19 in the javacode. Is there somebody who have had the same problem or is able to figure it out? Thanks.



fragment_main.xml


activity_main.xml
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're setting "activity_main" as the layout, not "fragment_main" - which contains the spinners.
 
Sven Sylta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:You're setting "activity_main" as the layout, not "fragment_main" - which contains the spinners.


Thanks. I changed it to setContentView(R.layout.fragment_main); but it still didn't work. Then I removed this part from the onCreate()-method:



then, for some reason, it worked.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!