Skip to content

Instantly share code, notes, and snippets.

@zyzo
Created April 1, 2014 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zyzo/3f84d5ec6fb58464b6fe to your computer and use it in GitHub Desktop.
Save zyzo/3f84d5ec6fb58464b6fe to your computer and use it in GitHub Desktop.
Android snippet - manipulating ImageSwitcher class
protected void onCreate(Bundle savedInstanceState) {
...
mImageSwitcher = (ImageSwitcher) findViewById(R.id.switcher1);
mImageSwitcher.setFactory(new ViewFactory() {
@Override
public View makeView() {
return new ImageView(GameActivity.this);
}
});
mImageSwitcher.setInAnimation(
AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
mImageSwitcher.setOutAnimation(
AnimationUtils.loadAnimation(this,android.R.anim.fade_out));
}
...
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
mImageSwitcher.setImageResource(imageIDs[position]);
mImageSwitcher.animate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment