O'Reilly logo

Android User Interface Development by Jason Morris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - turning on the TextSwitcher

We want the TextSwitcher to display the next listed comment every five seconds. For this we'll need to employ new resources, and a Handler object. A Handler is a way for Android applications and services to post messages between threads, and can also be used to schedule messages at a point in the future. It's a preferred structure to use over a java.util.Timer since a Handler object will not allocate a new Thread. In our case, a Timer is overkill, as there is only one task we want to schedule.

  1. Create a new XML file in your res/layout directory named review_comment.xml.
  2. Copy the following code into the new review_comment.xml file:
    <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="left|top" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required