reenadak

2019-12-23 creating toast in android.

Dec 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. package com.mukeshdak.a20191208;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.Toast;
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10.  
  11.     Button mdButton;
  12.  
  13.     @Override
  14.     protected void onCreate ( Bundle savedInstanceState ) {
  15.         super.onCreate ( savedInstanceState );
  16.         setContentView ( R.layout.activity_main );
  17.  
  18.         mdButton = findViewById ( R.id.mdButton );
  19.  
  20.         mdButton.setOnClickListener ( new View.OnClickListener () {
  21.             @Override
  22.             public void onClick ( View v ) {
  23.                 Toast.makeText ( getApplicationContext (), "Button is clicked", Toast.LENGTH_LONG ).show();
  24.             }
  25.         } );
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment