0 votes
29 views
How can we display a toast message in android onClick button ?
asked Dec 30, 2015 in Computer Science - IT by slow_learner (1,492 points) | 29 views

1 Answer

0 votes
Best answer

Assign  onClick attribute for button as below :

 button=(Button)findViewById(R.id.button1 );
        button.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "Hi Friends", Toast.LENGTH_LONG).show();
            }
        });

 

answered Dec 30, 2015 by slow_learner (1,492 points)