• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic