FileDocCategorySizeDatePackage
ImageSwitcher1.javaAPI DocGoogle Android v1.5 Example4287Sun Nov 11 13:01:04 GMT 2007com.google.android.samples.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 LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT));
        return i;
    
public voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);
        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.setSelectorSkin(getResources().getDrawable(android.R.drawable.box));
        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)