I want two images to keep changing continuously while the button is pressed down using ontouchlistener in ACTION_DOWN state..
I am using image view to switch images.
Here is the code i want to implement it, i am also playing the sound in loop with which i want to play two images simultaneously when ACTION_DOWN
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button zero = (Button) this.findViewById(R.id.button1);
zero.setOnTouchListener(this);
mp = MediaPlayer.create(this, R.raw.sound);
}
@Override
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
{
mp.setLooping(true);
mp.start();
}
break;
case MotionEvent.ACTION_UP:
{
mp.pause();
}
break;
}
return true;
}
}