Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 실시간 시계
- 성능지표
- bootstrap
- jinja2
- Action
- PyQt5
- VS Code
- #if
- OpenCV
- 명령어
- flask
- #ifndef
- 튜토리얼
- #undef
- 환경변수 설정
- heroku
- #else
- Django
- javascript
- #endif
- #ifdef
- DB 데이터
- 콘솔 가상환경 # 콘솔 #가상환경
- bootstrap4 패키지
- OpenCV + Flask
- openweathermap
- 사이트 도메인
- MySQL 세팅
- href
- DB 데이터 저장
Archives
- Today
- Total
PROGRAMMING
버튼-백그라운드컬러 본문
package com.example.a201103_1;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
public class MainActivity extends AppCompatActivity {
LinearLayout topLayout;
RadioGroup radioGroup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
topLayout = (LinearLayout) findViewById(R.id.topLayout);
radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId){
case R.id.radioButton:
topLayout.setBackgroundColor(Color.YELLOW);
break;
case R.id.radioButton2:
topLayout.setBackgroundColor(Color.CYAN);
break;
case R.id.radioButton3:
topLayout.setBackgroundColor(Color.MAGENTA);
break;
}
}
});
}
public void onClick(View view) {
switch(view.getId()){
case R.id.button:
topLayout.setBackgroundColor(Color.YELLOW);
break;
case R.id.button2:
topLayout.setBackgroundColor(Color.CYAN);
break;
case R.id.button3:
topLayout.setBackgroundColor(Color.MAGENTA);
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/buttonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="YELLOW"
android:textColor="#FFEB3B"
android:onClick="onClick"
app:backgroundTint="#2DFFFFFF" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CYAN"
android:textColor="#00BCD4"
android:onClick="onClick"
app:backgroundTint="#22FFFFFF" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="MAGENTA"
android:textColor="#673AB7"
android:onClick="onClick"
app:backgroundTint="#25FFFFFF" />
</LinearLayout>
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="YELLOW"
android:textColor="#FFEB3B" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CYAN"
android:textColor="#00BCD4" />
<RadioButton
android:id="@+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="MAGENTA"
android:textColor="#673AB7" />
</RadioGroup>
</LinearLayout>
'Android' 카테고리의 다른 글
ListViewEdit (0) | 2020.11.04 |
---|---|
ListView (0) | 2020.11.04 |
어플 접속화면(feat. 이상형월드컵) (0) | 2020.10.30 |
이상형월드컵(ver. teacher) (0) | 2020.10.30 |
AlertDialog (0) | 2020.10.30 |
Comments