Repository navigation
Expand file tree
/
Copy pathMainActivity2.java
More file actions
96 lines (67 loc) · 3.32 KB
/
Copy pathMainActivity2.java
File metadata and controls
96 lines (67 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.example.colorchange1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity2 extends AppCompatActivity {
View view;
ImageView back;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate ( savedInstanceState );
setContentView ( R.layout.activity_main2 );
back = (ImageView) findViewById ( R.id.bck2 );
TextView text = (TextView)findViewById(R.id.text);
Intent intent = getIntent();
String resmsg = intent.getStringExtra("message");
text.setText(resmsg);
if (resmsg.toString().equals("Red")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Bred );
} else if (resmsg.toString().equals("Orange")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Borange );
} else if (resmsg.toString().equals("Yellow")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Byellow );
} else if (resmsg.toString().equals("Green")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Bgreen );
} else if (resmsg.toString().equals("Blue")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Bblue );
} else if (resmsg.toString().equals("Indigo")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Bindigo );
} else if (resmsg.toString().equals("Violet")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Bviolet );
} else if (resmsg.toString().equals("White")) {
Toast.makeText ( MainActivity2.this, resmsg, Toast.LENGTH_SHORT ).show ();
view=this.getWindow ().getDecorView ();
view.setBackgroundResource ( R.color.Bwhite );
}
back.setOnClickListener ( new View.OnClickListener () {
@Override
public void onClick(View v) {
Toast.makeText ( MainActivity2.this, "You are Back To the Main Menu.", Toast.LENGTH_SHORT ).show ();
Move1 ();
finish ();
}
} );
}
public void Move1(){
Intent intent= new Intent ( MainActivity2.this, MainActivity.class );
startActivity ( intent );
}
}