FileDocCategorySizeDatePackage
TextSwitcher1.javaAPI DocGoogle Android v1.5 Example2548Sun Nov 11 13:01:04 GMT 2007com.google.android.samples.view

TextSwitcher1

public class TextSwitcher1 extends android.app.Activity implements ViewSwitcher.ViewFactory
Using a LogTextBox to display a scrollable text area to which text is appended.

Fields Summary
private static final String
TIME_FORMAT
private android.widget.TextSwitcher
mSwitcher
Calendar
mCalendar
Constructors Summary
Methods Summary
public android.view.ViewmakeView()

        TextView t = new TextView(this);
        t.setAlignment(Alignment.ALIGN_CENTER);
        t.setTextSize(36);
        return t;
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        setContentView(R.layout.text_switcher_1);

        mSwitcher = (TextSwitcher) findViewById(R.id.switcher);
        mSwitcher.setFactory(this);

        Animation in = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in);
        Animation out = AnimationUtils.loadAnimation(this,
                android.R.anim.fade_out);
        mSwitcher.setInAnimation(in);
        mSwitcher.setOutAnimation(out);

        mCalendar = Calendar.getInstance();

        Button nextButton = (Button) findViewById(R.id.next);
        nextButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                showTime();
            }
        });

        showTime();
    
private voidshowTime()

        mCalendar.setTimeInMillis(System.currentTimeMillis());
        mSwitcher.setText(DateFormat.format(TIME_FORMAT, mCalendar));