Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try this way:</p> <pre><code>imageSwitcher1 = (ImageSwitcher) findViewById(R.id.imageSwitcher1); imageSwitcher1.setFactory(this); imageSwitcher1.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); imageSwitcher1.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); imageSwitcher1.setImageResource(R.drawable.girl2); imageSwitcher1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { downX = (int) event.getX(); return true; } else if (event.getAction() == MotionEvent.ACTION_UP) { upX = (int) event.getX(); if (upX - downX &gt; 100) { imageSwitcher1.setInAnimation(AnimationUtils.loadAnimation(ShowPhotoActivity.this, android.R.anim.slide_in_left)); mageSwitcher1.setOutAnimation(AnimationUtils.loadAnimation(ShowPhotoActivity.this, android.R.anim.slide_out_right)); imageSwitcher1.setImageResource(R.drawable.girl1); } else if (downX - upX &gt; 100)// { imageSwitcher1.setInAnimation(AnimationUtils.loadAnimation(ShowPhotoActivity.this, android.R.anim.slide_in_left)); imageSwitcher1.setOutAnimation(AnimationUtils.loadAnimation(ShowPhotoActivity.this, android.R.anim.slide_out_right)); imageSwitcher1.setImageResource(R.drawable.girl2); } return true; } return false; } }; </code></pre> <p>and if u have image array then try this:</p> <pre><code>imgSwitcher.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { downX = (int) event.getX(); Log.i("event.getX()", " downX " + downX); return true; } else if (event.getAction() == MotionEvent.ACTION_UP) { upX = (int) event.getX(); Log.i("event.getX()", " upX " + downX); if (upX - downX &gt; 100) { imgSwitcher.setInAnimation(AnimationUtils .loadAnimation(firstActivity.this, android.R.anim.slide_in_left)); imgSwitcher.setOutAnimation(AnimationUtils .loadAnimation(firstActivity.this, android.R.anim.slide_out_right)); //curIndex current image index in array viewed by user curIndex--; if (curIndex &lt; 0) { curIndex = 5; } //IMAGE_LIST :-image list array imgSwitcher.setImageResource(IMAGE_LIST[curIndex]); firstActivity.this.switchTitle(curIndex); } else if (downX - upX &gt; 100) { imgSwitcher.setInAnimation(AnimationUtils .loadAnimation(firstActivity.this, R.anim.slide_out_left)); imgSwitcher.setOutAnimation(AnimationUtils .loadAnimation(firstActivity.this, R.anim.slide_in_right)); curIndex++; if (curIndex &gt; 5) { curIndex = 0; } imgSwitcher.setImageResource(IMAGE_LIST[curIndex]); firstActivity.this.switchTitle(curIndex); } return true; } return false; } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload