import android.widget.*; import android.view.*; import android.content.Context; import android.app.Activity; import java.util.Timer; import java.util.TimerTask; public class main { static class Lg { ScrollView sv; TextView tv; StringBuilder buf = new StringBuilder(); Lg(Activity context) { sv = new ScrollView(context); tv = new TextView(context); tv.setText(buf.toString()); sv.addView(tv); } View getView() { return sv; } void print(String s) { buf.append(s); tv.setText(buf.toString()); } void println(String s) { print(s + "\n"); } } static Lg log; public static View main(final Activity context) { log = new Lg(context); Timer myTimer = new Timer(); myTimer.schedule(new TimerTask() { public void run() { context.runOnUiThread(new Runnable() { public void run() { log.println("More text"); } }); } }, 0, 1000); return log.getView(); } }