티스토리 뷰
Day.java
package com.jwsoft.javaproject;
enum Day {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">
<Button
android:id="@+id/btnMonday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Monday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
<Button
android:id="@+id/btnTuesday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Tuesday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
<Button
android:id="@+id/btnWednesday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Wednesday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
<Button
android:id="@+id/btnThursday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Thursday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
<Button
android:id="@+id/btnFriday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Friday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
<Button
android:id="@+id/btnSaturday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Saturday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
<Button
android:id="@+id/btnSunday"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="Sunday"
android:textSize="20dp"
android:textStyle="bold|italic"
android:onClick="onClick"/>
</LinearLayout>
MainActivity.java
package com.jwsoft.javaproject;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Day day;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnMonday: {
day = Day.Monday;
break;
}
case R.id.btnTuesday: {
day = Day.Tuesday;
break;
}
case R.id.btnWednesday: {
day = Day.Wednesday;
break;
}
case R.id.btnThursday: {
day = Day.Thursday;
break;
}
case R.id.btnFriday: {
day = Day.Friday;
break;
}
case R.id.btnSaturday: {
day = Day.Saturday;
break;
}
case R.id.btnSunday: {
day = Day.Sunday;
break;
}
default:
break;
}
Toast.makeText(getApplicationContext(), day.toString(), Toast.LENGTH_SHORT).show();
}
}
'Android > Java' 카테고리의 다른 글
[Java] ProgressBar (0) | 2020.08.07 |
---|---|
[Java] BuildConfig (0) | 2020.08.07 |
[Java] Generics (2) (0) | 2020.08.06 |
[Java] Toolbar + include (0) | 2020.08.05 |
[Java] ImageView 타원화 (0) | 2020.08.04 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- JSONObject
- 혀가 길지 않은 개발자
- 자바
- ViewPager2
- MVVM
- activity
- recyclerview
- ViewModel
- Design Pattern
- DataBinding
- Architecture Pattern
- James Kim
- Kotlin
- Livedata
- JSONArray
- 안드로이드
- Android
- View
- CoordinatorLayout
- 안드로이드 #코틀린 #Android #Kotlin
- XML
- java
- TabLayout
- ArrayList
- Vue.js #Vue.js + javascript
- handler
- 코틀린
- coroutine
- fragment
- Intent
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함