1. Previous 버튼 추가
(1) xml에 버튼 추가
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/previous_button"
android:drawableEnd="@drawable/arrow_left"
android:drawablePadding="4dp"
android:layout_marginRight="10dp"
android:text="@string/previous_button"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/next_button"
android:drawableEnd="@drawable/arrow_right"
android:drawablePadding="4dp"
android:text="@string/next_button"/>
</LinearLayout>
(2) 코틀린에 다음 문장들 각각 알맞은 위치에 추가
private lateinit var prevButton: Button
prevButton = findViewById(R.id.previous_button)
prevButton.setOnClickListener {
currentIndex = (currentIndex - 1 + questionBank.size) % questionBank.size
updateQuestion()
}
2. Button을 ImageButton으로 변경
(1) xml 변경
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/previous_button"
android:src="@drawable/arrow_left"
android:layout_marginRight="10dp"
android:contentDescription="@string/previous_button"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/next_button"
android:src="@drawable/arrow_right"
android:contentDescription="@string/next_button"/>
</LinearLayout>
(2) 코틀린 변경
private lateinit var nextButton: ImageButton
private lateinit var prevButton: ImageButton
'DEVELOPMENT' 카테고리의 다른 글
카페24 SSL 보안인증서 https로 리다이렉트 (0) | 2021.07.23 |
---|---|
[실무에 바로 적용하는 안드로이드 프로그래밍] Chapter 3 (0) | 2021.07.17 |
[실무에 바로 적용하는 안드로이드 프로그래밍 - Kotlin] Challenge 1: Toast Customizing (0) | 2021.07.13 |
[Android Studio] Chapter 14 연습문제 (0) | 2021.07.09 |
[Android Studio] Chapter 14 직접 풀어보기 (0) | 2021.07.09 |