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

ImageSwitcher1

public class ImageSwitcher1 extends android.app.Activity implements ViewSwitcher.ViewFactory, AdapterView.OnItemSelectedListener

Fields Summary
private android.widget.ImageSwitcher
mSwitcher
private Integer[]
mThumbIds
private Integer[]
mImageIds
Constructors Summary
Methods Summary
public android.view.ViewmakeView()

        ImageView i = new ImageView(this);
        i.setBackgroundColor(0xFF000000);
        i.setScaleType(ImageView.ScaleType.FIT_CENTER);
        i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT));
        return i;
    
public voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.image_switcher_1);

        mSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
        mSwitcher.setFactory(this);
        mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in));
        mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
                android.R.anim.fade_out));

        Gallery g = (Gallery) findViewById(R.id.gallery);
        g.setAdapter(new ImageAdapter(this));
        g.setOnItemSelectedListener(this);
    
public voidonItemSelected(android.widget.AdapterView parent, android.view.View v, int position, long id)

        mSwitcher.setImageResource(mImageIds[position]);
    
public voidonNothingSelected(android.widget.AdapterView parent)