일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- git flow
- html id
- #2차원배열
- html charset
- hyperledger transaction
- #JAVASCRIPT
- html youtube
- relative path
- #자바상속#자바이즈어#is~a
- html code
- mac terminal command
- docker example
- #CallByAddress
- border-box
- 토큰경제
- html object
- 하이퍼레저패브릭
- html plug-in
- #다차원포인터
- html5 new tag
- #binary
- #bubbleSort
- #android activity
- html video
- #1차원배열
- #3차원배열
- #성적관리프로그램
- html multimedia
- #C++ has~a
- #C++ 연산자함수오버로딩
Archives
- Today
- Total
A sentimental robot
OnTouch 본문
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.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button=findViewById(R.id.button1);
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:{
Button button2 = findViewById(R.id.button2);
float x = button2.getX();
x += 20.0f;
button2.setX(x);
}break;
case MotionEvent.ACTION_MOVE:{
Button button2 = findViewById(R.id.button2);
int w = button2.getWidth();
w += 10;
button2.setWidth(w);
}break;
case MotionEvent.ACTION_UP:{
Button button2 = findViewById(R.id.button2);
Random rnd=new Random();
int r=rnd.nextInt(256);
int g=rnd.nextInt(256);
int b=rnd.nextInt(256);
button2.setBackgroundColor(Color.argb(0xff,r,g,b));
}break;
}
return false;
}
});
}
}
'Android Studio' 카테고리의 다른 글
My xml (0) | 2018.02.06 |
---|---|
Customizing (0) | 2018.02.06 |
RelativeLayout (0) | 2018.02.06 |
Handler (0) | 2018.02.05 |
GridLayout2 (0) | 2018.02.05 |