Tuesday 12 February 2013

How to set a Listener for Button in Android ?


Button button= (Button) findViewById(R.id.button);

            button.setOnClickListener(new OnClickListener() {

                  public void onClick(View v) {
                        // TODO Auto-generated method stub

        Toast.makeText(getApplicationContext(), "Button Clicked",
                                    Toast.LENGTH_LONG).show();
                  }
            });

No comments:

Post a Comment