Advertisement
bhushan23

buttonclick

Dec 19th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package com.example.click;
  2.  
  3. import android.os.Bundle;
  4. import android.widget.Toast;
  5. import android.app.Activity;
  6. import android.view.Menu;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9. import android.widget.*;
  10. import android.view.*;
  11. public class click extends Activity {
  12.  
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.activity_click);
  17.         Button bt1 ;
  18.         bt1=(Button)findViewById(R.id.btn);
  19.         bt1.setOnClickListener(new View.OnClickListener()
  20.        
  21.         {
  22.             @Override
  23.             public void onClick(View arg0) {
  24.                 // TODO Auto-generated method stub
  25.                 prnt();
  26.             }
  27.         });
  28.         bt1.setOnLongClickListener(new View.OnLongClickListener() {
  29.            
  30.             @Override
  31.             public boolean onLongClick(View arg1) {
  32.                 // TODO Auto-generated method stub
  33.                 prntl();
  34.                 return false;
  35.             }
  36.         });
  37.     }
  38.     public void prntl()
  39.     {
  40.         Toast.makeText(this, "long press", Toast.LENGTH_SHORT).show();
  41.     }
  42. public void prnt()
  43. {
  44.     Toast.makeText(this,"clicked",Toast.LENGTH_LONG).show();}
  45.     @Override
  46.     public boolean onCreateOptionsMenu(Menu menu) {
  47.         // Inflate the menu; this adds items to the action bar if it is present.
  48.         getMenuInflater().inflate(R.menu.activity_flshlight, menu);
  49.         return true;
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement