Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

Chapter 2  Android and Model-View-Controller


You can replace the text and drawable attributes on the next button with a single ImageView attribute:


<Button ImageButton
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next_button"
android:drawableRight="@drawable/arrow_right"
android:drawablePadding="4dp"
android:src="@drawable/arrow_right"
/>


Of course, you will need to modify QuizActivity to work with ImageButton.


After you have changed these buttons to ImageButtons, Android Studio will warn you about a missing
android:contentDescription attribute. This attribute supports accessibility for users with vision
impairments. You set the value to a string, which is read aloud when users have the appropriate settings
applied.


Add an android:contentDescription attribute to each ImageButton to complete the challenge.

Free download pdf