Advertisement
heru-kzw

tombol2

Dec 11th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. // tombol intetn (pidah halaman )
  2. imvFriend=(ImageView)findViewById(R.id.imvFriend);
  3.         imvFriend.setOnClickListener(new View.OnClickListener() {
  4.         public void onClick(View arg0) {
  5.             Intent i = new Intent(Menuutama.this,listPeserta.class);
  6.                 startActivity(i);
  7.     }});
  8.  
  9. >>>>>>>>>>>>>Splas screen<<<<<<<<<<
  10.  Loading();
  11.     }
  12.  
  13.     @Override
  14.     public boolean onCreateOptionsMenu(Menu menu) {
  15.         // Inflate the menu; this adds items to the action bar if it is present.
  16.         getMenuInflater().inflate(R.menu.activity_main, menu);
  17.         return true;
  18.     }
  19.  
  20. public void Loading(){
  21.  new Thread() {
  22.    public void run() {
  23.       try{Thread.sleep(5000);}
  24.       catch (Exception e) {}
  25.             Intent i = new Intent(Loading.this, Login.class);
  26.             Loading.this.finish();
  27.            startActivity(i);
  28.      } }.start();
  29.  
  30. }
  31. }
  32.  
  33.  
  34. >>>>>>>>>Pertanyaan YES/No <<<<<<<
  35.  
  36. public void keluar(){
  37.      new AlertDialog.Builder(this)
  38.   .setTitle("Menutup Aplikasi")
  39.   .setMessage("Terimakasih... Anda Telah Menggunakan Lp2m Aray heru")
  40.   .setNeutralButton("Tutup", new DialogInterface.OnClickListener() {
  41.    public void onClick(DialogInterface dlg, int sumthin) {
  42.    finish();
  43.    }})
  44.   .show();
  45.     }
  46.     public void keluarYN(){
  47.      AlertDialog.Builder ad=new AlertDialog.Builder(Menuutama.this);
  48.              ad.setTitle("Konfirmasi");
  49.              ad.setMessage("Apakah benar ingin keluar?");
  50.              
  51.              ad.setPositiveButton("OK",new OnClickListener(){
  52.           @Override
  53.        public void onClick(DialogInterface dialog, int which) {
  54.          keluar();
  55.         }});
  56.              
  57.              ad.setNegativeButton("No",new OnClickListener(){
  58.            public void onClick(DialogInterface arg0, int arg1) {
  59.            }});
  60.              
  61.              ad.show();
  62.     }
  63. >>>>>>>>>>>>>>>>>>>Kode back (agar tidak nenumpuk ketika di back )<<<<<<<<
  64.     public boolean onKeyDown(int keyCode, KeyEvent event) {
  65.         if (keyCode == KeyEvent.KEYCODE_BACK) {
  66.          keluarYN();
  67.                 return true;
  68.         }
  69.     return super.onKeyDown(keyCode, event);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement