Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Android Studio (Java) - counter doesn't update & app crash on empty input

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First time doing Android Studio and I encountered these errors where my counter will not increase and my app crashes on null input.

Any ideas? Tried for like an hour to get my head around it, but I just can't see why it's not doing it.

Edit:
Counter output should increase depending on how many times the same number is guessed

img.png
[Thumbnail for img.png]
Image of GUI
 
Denis Neagu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not sure why it fixed it, but it worked

put counter as global var & created a public void for it then called it
 
Sheriff
Posts: 17489
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt a global variable is the proper way to do this. See https://developer.android.com/topic/libraries/architecture/saving-states

Also, this is redundant and looks confused:

Not sure what you think you're doing there but it's equivalent to this:

 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic