-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.java
30 lines (25 loc) · 988 Bytes
/
MainActivity.java
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
package com.example.nino.firstapp;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.textView);
final EditText edit = (EditText) findViewById(R.id.editText);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Random randomcolor = new Random();
int color = Color.argb(255, randomcolor.nextInt(256), randomcolor.nextInt(256), randomcolor.nextInt(256));
edit.setTextColor(color);
}
});
}
}