• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The Application has stopped unexpectedly please try again {com.android.internal.os.ZygoteInit$Meth}

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying my first Android app with 2 text and 2 Buttons
the app is working fine and also getting loaded in {AVD} but when i click one of the button it stops saying "stopped unexpectedly please try again"

The XML code is
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


The Main Activity java code is
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



I thought the error is due to the Android Version i am using on Emulator but even tried it with 5.0.1 and 5.1.1 and also with target AVD 2.2
But still the same error

Thanks in advance
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's because TextView.setText(int) doesn't do what you think it does. From http://developer.android.com/reference/android/widget/TextView.html#setText(int) , the int argument is treated as a resource ID of a string resource. When you set setText(count), android goes looking for a string resource with ID=value of count, doesn't find it and crashes. The logcat exception trace will have revealed that.

Use Integer.toString(count) to set the text.
...
And never assume anything about an API. Javadocs are your friend ;)
 
Rohit Gaikwad
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Really Thanks Karthik Shiraly
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic