package com.example.i310_54.myapplication08;
import android.graphics.Color;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
String TAG="EUNBI";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Handler handler;
public void f1(View view) {
handler=new Handler(){
int r,g,b;
Random rnd=new Random();
LinearLayout ll=findViewById(R.id.ll);
@Override
public void handleMessage(Message msg) {
handler.sendEmptyMessageDelayed(0,1000);
r=rnd.nextInt(256);
g=rnd.nextInt(256);
b=rnd.nextInt(256);
ll.setBackgroundColor(Color.argb(0xff,r,g,b));
}
};
handler.sendEmptyMessage(0);
}
public void f2(View view) {
handler.removeMessages(0);
Button button3=findViewById(R.id.button3);
button3.setEnabled(false);
}
}