• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Marshal
Posts: 14339
237
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • 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:

 
please buy this thing and then I get a fat cut of the action:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!