Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.Kalkulator;
- import androidx.appcompat.app.AppCompatActivity;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Vibrator;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.ImageView;
- import android.widget.MediaController;
- import android.widget.Spinner;
- import android.widget.Toast;
- import android.widget.VideoView;
- import java.util.Random;
- public class MainActivity6 extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
- int spinner_selected = 0;
- VideoView video;
- Spinner spinner3;
- int klik = 0;
- public void otvoriMainActivity(){
- Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- v.vibrate(1);
- Intent intent = new Intent(this, MainActivity.class);
- startActivity(intent);
- }
- public void otvoriMainActivity2(){
- Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- v.vibrate(1);
- Intent intent = new Intent(this, MainActivity2.class);
- startActivity(intent);
- }
- public void otvoriMainActivity3(){
- Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- v.vibrate(1);
- Intent intent = new Intent(this, MainActivity3.class);
- startActivity(intent);
- }
- public void otvoriMainActivity4(){
- Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- v.vibrate(1);
- Intent intent = new Intent(this, MainActivity4.class);
- startActivity(intent);
- }
- public void otvoriMainActivity5(){
- Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- v.vibrate(1);
- Intent intent = new Intent(this, MainActivity5.class);
- startActivity(intent);
- }
- public void video_horiz(View view) {
- if(klik == 0){
- video = findViewById(R.id.video);
- String path = "android.resource://" + getPackageName() + "/" + R.raw.video_landsc;
- Uri uri = Uri.parse(path);
- video.setVideoURI(uri);
- MediaController mediacon = new MediaController(this);
- video.setMediaController(mediacon);
- mediacon.setAnchorView(video);
- }
- klik++;
- }
- public void video_vertical(View view) {
- if(klik == 0){
- video = findViewById(R.id.video);
- String path = "android.resource://" + getPackageName() + "/" + R.raw.underwater_video;
- Uri uri = Uri.parse(path);
- video.setVideoURI(uri);
- MediaController mediacon = new MediaController(this);
- video.setMediaController(mediacon);
- mediacon.setAnchorView(video);
- }
- klik++;
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main6);
- spinner3 = findViewById(R.id.spinner3);
- ArrayAdapter<CharSequence> adapter3 = ArrayAdapter.createFromResource(this, R.array.menu_MainActivity6, R.layout.dropdown_button);
- adapter3.setDropDownViewResource(R.layout.dropdown_item);
- spinner3.setAdapter(adapter3);
- spinner3.setOnItemSelectedListener(this);
- }
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- String text = parent.getItemAtPosition(position).toString();
- if (spinner_selected > 0) {
- switch (text) {
- case "\uD83E\uDDEE":
- otvoriMainActivity();
- SingleToast.show(getApplicationContext(), text, Toast.LENGTH_SHORT);
- break;
- case "\uD83D\uDCCF":
- otvoriMainActivity2();
- SingleToast.show(getApplicationContext(), text, Toast.LENGTH_SHORT);
- break;
- case "\uD83C\uDFB2":
- otvoriMainActivity3();
- SingleToast.show(getApplicationContext(), text, Toast.LENGTH_SHORT);
- break;
- case "\uD83C\uDF7E":
- otvoriMainActivity5();
- SingleToast.show(getApplicationContext(), text, Toast.LENGTH_SHORT);
- break;
- case "\uD83E\uDE99":
- otvoriMainActivity4();
- SingleToast.show(getApplicationContext(), text, Toast.LENGTH_SHORT);
- break;
- }
- }
- spinner_selected++;
- }
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement