我开发的,我想滑动的手指触摸图片Android应用程序。我已实施 onClickListener
与我的幻灯片图像,但我不知道如何实现手指触摸功能。
I am developing an android application in which I want to slide images with finger touch. I have implemented an onClickListener
with which I can slide images but I don't know how to implement finger touch functionality.
请给我建议任何方法如何滑动的手指触摸图片。任何建议或任何教程或方法会有所帮助。
Please suggest me any method how to slide images with finger touch. Any Suggestion or any tutorial or method will be helpful.
您可以使用onTouchListner方法,而不是onClickListner。下面onTouchListners例说明。
You can use onTouchListner method instead of onClickListner. Below onTouchListners example is given..
public class abc extends Activity implements OnTouchListener
{
ImageView img;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.one);
img = (ImageView) findViewById(R.id.imageView1);
img.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
{
// Here u can write code which is executed after the user touch on the screen
break;
}
case MotionEvent.ACTION_UP:
{
// Here u can write code which is executed after the user release the touch on the screen
break;
}
case MotionEvent.ACTION_MOVE:
{
// Here u can write code which is executed when user move the finger on the screen
break;
}
}
return true;
}