-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ning/app/src/main/java/com/hatenablog/atuyan39/androidtraining/TrainingRadioActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.hatenablog.atuyan39.androidtraining; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
public class TrainingRadioActivity extends AppCompatActivity { | ||
private TextView mTextView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_training_radio); | ||
|
||
// Viewを取得 | ||
mTextView = findViewById(R.id.radio_1_text_view); | ||
} | ||
|
||
/** | ||
* Called when a radio button has been clicked. | ||
* | ||
* @param view the view that was clicked | ||
*/ | ||
public void onRadioButtonClicked(View view) { | ||
switch (view.getId()) { | ||
case R.id.radio_1_radio_a: | ||
mTextView.setText(R.string.radio_1_blood_type_a); | ||
break; | ||
case R.id.radio_1_radio_b: | ||
mTextView.setText(R.string.radio_1_blood_type_b); | ||
break; | ||
case R.id.radio_1_radio_o: | ||
mTextView.setText(R.string.radio_1_blood_type_o); | ||
break; | ||
case R.id.radio_1_radio_ab: | ||
mTextView.setText(R.string.radio_1_blood_type_ab); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
AndroidTraining/app/src/main/res/layout/activity_training_radio.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".TrainingRadioActivity"> | ||
|
||
<RadioGroup | ||
android:id="@+id/radioGroup" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_1_radio_a" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:onClick="onRadioButtonClicked" | ||
android:text="@string/radio_1_blood_type_a" /> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_1_radio_b" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:onClick="onRadioButtonClicked" | ||
android:text="@string/radio_1_blood_type_b" /> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_1_radio_o" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:onClick="onRadioButtonClicked" | ||
android:text="@string/radio_1_blood_type_o" /> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_1_radio_ab" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:onClick="onRadioButtonClicked" | ||
android:text="@string/radio_1_blood_type_ab" /> | ||
</RadioGroup> | ||
|
||
<TextView | ||
android:id="@+id/radio_1_text_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/radioGroup" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters