Advertisement
mhdew

java of main activity

Apr 5th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1. package com.example.converterproject;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.view.Window;
  9. import android.view.WindowManager;
  10. import android.widget.Button;
  11. import android.widget.ImageView;
  12. import android.widget.ViewFlipper;
  13.  
  14. public class MainActivity extends AppCompatActivity {
  15.  
  16.     Button enc,dec,abt;
  17.     ViewFlipper vf;
  18.  
  19.     @Override
  20.     protected void onCreate(Bundle savedInstanceState) {
  21.         super.onCreate(savedInstanceState);
  22.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  23.         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  24.         setContentView(R.layout.activity_main);
  25.  
  26.         enc=findViewById(R.id.encd);
  27.         dec=findViewById(R.id.decd);
  28.         abt=findViewById(R.id.abut);
  29.  
  30.         enc.setOnClickListener(new View.OnClickListener() {
  31.             @Override
  32.             public void onClick(View v) {
  33.                 Intent temp = new Intent(MainActivity.this,encoder.class);
  34.                 startActivity(temp);
  35.             }
  36.         });
  37.  
  38.         dec.setOnClickListener(new View.OnClickListener() {
  39.             @Override
  40.             public void onClick(View v) {
  41.                 Intent temp = new Intent(MainActivity.this,decoder.class);
  42.                 startActivity(temp);
  43.             }
  44.         });
  45.  
  46.         abt.setOnClickListener(new View.OnClickListener() {
  47.             @Override
  48.             public void onClick(View v) {
  49.                 Intent temp = new Intent(MainActivity.this,about.class);
  50.                 startActivity(temp);
  51.             }
  52.         });
  53.  
  54.  
  55.         //Code of slideshow starts
  56.         vf=findViewById(R.id.vf);
  57.  
  58.         //paste the photos in drawable. Add them to this image array with format R.drawable.filename
  59.         int images[] = {R.drawable.bellaso_cipher, R.drawable.caesar_cipher_encryption, R.drawable.dorabella_cipher, R.drawable.skytale, R.drawable.the_ave_maria_code, R.drawable.the_voynich_manuscript};
  60.  
  61.         for(int i=0;i<images.length;i++){
  62.             flipper(images[i]);
  63.         }
  64.         //Code of slideshow starts
  65.  
  66.     }
  67.  
  68.     public void flipper(int images){
  69.         ImageView test = new ImageView(this);
  70.         test.setBackgroundResource(images);
  71.  
  72.         vf.addView(test);
  73.         vf.setFlipInterval(3000);
  74.         vf.setAutoStart(true);
  75.  
  76.         vf.setInAnimation(this, android.R.anim.slide_in_left);
  77.         vf.setOutAnimation(this, android.R.anim.slide_out_right);
  78.     }
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement