Yorumlar

Ahmet Burak Demirkoparan
10 yıl 2 ay önce
Teşekkür ederim. Benim aklıma da tek o geldi ama keyleri neye gönderebiliriz? Textview' a falan mı?
Ahmet Burak Demirkoparan
10 yıl 2 ay önce
<?xml version="1.0" encoding="utf-8"?> imageList.length-1) { curIndex = 0; } imageSwitcher.setInAnimation(AnimationUtils .loadAnimation(Main.this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils .loadAnimation(Main.this, android.R.anim.fade_out)); imageSwitcher.setImageResource(imageList[curIndex]); } }); imageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); imageSwitcher.setFactory(this); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); imageSwitcher.setImageResource(imageList[curIndex]); imageSwitcher.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { 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 > 100) { curIndex--; if (curIndex < 0) { curIndex = imageList.length - 1; } imageSwitcher.setInAnimation(AnimationUtils .loadAnimation(Main.this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils .loadAnimation(Main.this, android.R.anim.fade_out)); imageSwitcher.setImageResource(imageList[curIndex]); } else if (downX - upX > -100) { curIndex++; if (curIndex > imageList.length-1) { curIndex = 0; } imageSwitcher.setInAnimation(AnimationUtils .loadAnimation(Main.this, android.R.anim.fade_in)); imageSwitcher.setOutAnimation(AnimationUtils .loadAnimation(Main.this, android.R.anim.fade_out)); imageSwitcher.setImageResource(imageList[curIndex]); } return true; } return false; } }); } @Override public View makeView() { ImageView i = new ImageView(this); i.setScaleType(ImageView.ScaleType.FIT_CENTER); return i; } }