File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes public void onClick(View v) {    // error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "public void onClick(View v) {    // error" Watch "public void onClick(View v) {    // error" New topic

public void onClick(View v) { // error

Ethan Bauer

Joined: Sep 22, 2010
Posts: 18
My problem is fully described:

The Problems tab show me 0 errors but 38 warnings, the app crashes when I click on the button.
Dave MacLean
Ranch Hand

Joined: May 10, 2011
Posts: 49

It's difficult to troubleshoot this without seeing the stack trace of the error. I'm also suspicious because if the setContentView() method was the problem, you wouldn't have a button to click because the app would have already crashed before you got that far (I'm referring to your post at One thing I see that is not good is how you check which button is clicked. The usual thing that developers do is something like this:

if( v.getId() == )


switch( v.getId() ) {

- dave

Dave MacLean our book (Pro Android 4)
I agree. Here's the link:
subject: public void onClick(View v) { // error
It's not a secret anymore!