492 CHAPTER 13: Android Service Class and Threads: Background Processing
activity_play.xml user interface definition file. This file is used to hold the
container and the
will be adding the
Figure 13-8. Copy the sound0.png and sound1.png PNG32 images into the /HelloUniverse/res/drawable-hdpi folder
After that is in place, you will be able to get into the Java programming part, which is the more
difficult part of this task, but also where you will learn some cool new tricks. You will declare
and instantiate your ImageView objects and “wire them up” with event handlers using the
.setOnClickListener( ) method calls. Inside these (one for each audio control icon), you will have
an onClick( ) event handler method, which will contain your .startService( ) method call for the
playAudio icon and the .stopService( ) method call for the stop Audio icon.
Setting Up Your UI Design Using XML and Java
This section sets up the UI:
- Since you are going to be using ImageView UI widgets, which
like the ImageButton UI widgets require that you implement an
android:contentDescription parameter for the sight impaired, the first
thing that you need to do is add twoconstants in your
/res/values/strings.xml file named play_audio and stop_audio.