The following code is from 
http://developer.android.com/guide/topics/ui/ui-events.html
and shows how to handle a click on a button (called corky, I think)
If I had several (say 10) buttons on a form, each launching a
different subscreen, would I have to find and repeat the
setOnClickListener statement for each button, then put a switch
statement in the onClick subroutine, or is there a better way to do
it? (I'd rather not resort to naming my buttons Button1, Button2 etc
and using a loop)

public class ExampleActivity extends Activity implements
OnClickListener {
    protected void onCreate(Bundle savedValues) {
        ...
        Button button = (Button)findViewById(R.id.corky);
        button.setOnClickListener(this);
    }

    // Implement the OnClickListener callback
    public void onClick(View v) {
      // do something when the button is clicked
    }
    ...
}

TIA,

- Frink

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to