Commit 92f0142c by likorn

Replaced buttons inside cardViews with text views

parent 1a3a2aa2
......@@ -2,8 +2,9 @@ package com.example.quickmax
import android.os.Bundle
import android.os.CountDownTimer
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
......@@ -20,8 +21,8 @@ class MainActivity : AppCompatActivity() {
private fun setUpAnswerButtons() {
for (answer in answerSet) {
findViewById<Button>(answer.buttonId).text = answer.value.toString()
findViewById<Button>(answer.buttonId).setOnClickListener { processAnswer(answer.correct) }
(findViewById<CardView>(answer.buttonId).getChildAt(0) as TextView).text = answer.value.toString()
findViewById<CardView>(answer.buttonId).setOnClickListener { processAnswer(answer.correct) }
}
}
......@@ -41,7 +42,7 @@ class MainActivity : AppCompatActivity() {
private fun makeRadioButtonsUncheckable() {
for (answer in answerSet) {
findViewById<Button>(answer.buttonId).isClickable = false
findViewById<CardView>(answer.buttonId).isClickable = false
}
}
......
......@@ -21,49 +21,47 @@
app:layout_constraintVertical_chainStyle="packed">
<androidx.cardview.widget.CardView
android:id="@+id/cv_left_top"
android:id="@+id/btn_left_top"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintBottom_toTopOf="@+id/cv_left_bottom"
app:layout_constraintEnd_toStartOf="@+id/cv_right_top"
app:layout_constraintBottom_toTopOf="@+id/btn_left_bottom"
app:layout_constraintEnd_toStartOf="@+id/btn_right_top"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<Button
android:id="@+id/btn_left_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FFFFFF" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cv_right_top"
android:id="@+id/btn_right_top"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintBottom_toTopOf="@id/cv_right_bottom"
app:layout_constraintBottom_toTopOf="@id/btn_right_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/cv_left_top"
app:layout_constraintStart_toEndOf="@+id/btn_left_top"
app:layout_constraintTop_toTopOf="parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<Button
android:id="@+id/btn_right_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FFFFFF" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cv_left_bottom"
android:id="@+id/btn_left_bottom"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="8dp"
......@@ -71,20 +69,19 @@
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/cv_right_bottom"
app:layout_constraintEnd_toStartOf="@+id/btn_right_bottom"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cv_left_top" >
app:layout_constraintTop_toBottomOf="@+id/btn_right_top" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<Button
android:id="@+id/btn_left_bottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FFFFFF" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cv_right_bottom"
android:id="@+id/btn_right_bottom"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="8dp"
......@@ -94,14 +91,13 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/cv_left_bottom"
app:layout_constraintTop_toBottomOf="@+id/cv_right_top" >
app:layout_constraintStart_toEndOf="@+id/btn_left_bottom"
app:layout_constraintTop_toBottomOf="@+id/btn_right_top" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<Button
android:id="@+id/btn_right_bottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FFFFFF" />
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment