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" ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.