FileDocCategorySizeDatePackage
TextSwitcher1.javaAPI DocAndroid 1.5 API2296Wed May 06 22:41:08 BST 2009com.example.android.apis.view

TextSwitcher1

public class TextSwitcher1 extends android.app.Activity implements ViewSwitcher.ViewFactory, View.OnClickListener
Uses a TextSwitcher.

Fields Summary
private android.widget.TextSwitcher
mSwitcher
private int
mCounter
Constructors Summary
Methods Summary
public android.view.ViewmakeView()

        TextView t = new TextView(this);
        t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
        t.setTextSize(36);
        return t;
    
public voidonClick(android.view.View v)

        mCounter++;
        updateCounter();
    
protected voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);

        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);

        Button nextButton = (Button) findViewById(R.id.next);
        nextButton.setOnClickListener(this);

        updateCounter();
    
private voidupdateCounter()

        mSwitcher.setText(String.valueOf(mCounter));