I am trying to test the capabilities of the interface and the timer. So I tried the following exercise:
=== TestTimerActivity.java ===
package com.tvt.TestTimer; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import java.util.Timer; import java.util.TimerTask; public class TestTimerActivity extends Activity { TextView _tv; Timer _t; int _count = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
=== TestTimerActivity.java ===
=== main.xml ===
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/header" android:id="@+id/TestViewHeader" android:textStyle="bold"/> <TextView android:layout_height="wrap_content" android:id="@+id/TextViewTime" android:layout_width="match_parent" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" android:text="-"></TextView> </LinearLayout>
=== main.xml ===
The very first call to UpdateTime (from onCreate) completes OK, but the same call from TimerTask :: run () does not give the message "TestTimer class stopped unexpectedly."
Any idea? Where is my fault?
-
SY, TVT
source share