Android Open Source - TouchImageView Switch Image Example Activity






From Project

Back to project page TouchImageView.

License

The source code is released under:

opyright (c) 2012 Michael Ortiz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softw...

If you think the Android project TouchImageView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ortiz.touch;
// w w  w. ja  v a 2 s  .c  o m
import com.example.touch.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class SwitchImageExampleActivity extends Activity {
  
  private TouchImageView image;
  private static int[] images = { R.drawable.nature_1, R.drawable.nature_2, R.drawable.nature_3, R.drawable.nature_4 };
  int index;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_switch_image_example);
    image = (TouchImageView) findViewById(R.id.img);
    index = 0;
    //
    // Set first image
    //
    setCurrentImage();
    //
    // Set next image with each button click
    //
    image.setOnClickListener(new OnClickListener() {
      
      @Override
      public void onClick(View v) {
        setCurrentImage();
      }
    });
  }
  
  private void setCurrentImage() {
    image.setImageResource(images[index]);
    index = (++index % images.length);
  }

}




Java Source Code List

com.ortiz.touch.ExtendedViewPager.java
com.ortiz.touch.MainActivity.java
com.ortiz.touch.MirroringExampleActivity.java
com.ortiz.touch.SingleTouchImageViewActivity.java
com.ortiz.touch.SwitchImageExampleActivity.java
com.ortiz.touch.SwitchScaleTypeExampleActivity.java
com.ortiz.touch.TouchImageView.java
com.ortiz.touch.ViewPagerExampleActivity.java