I want to set the image named "pic" in the ImageView as long as the screen is touched. I am a beginner and don't what the code should be in the cases of MotionEvent , can someone help me with this. This is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.frame);
fl = (FrameLayout)findViewById(R.id.titlescreenframe);
screen=(ImageView)findViewById(R.id.imageView1);
fl.setOnTouchListener(new View.OnTouchListener() {
@Override public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
//WHAT CODE SHOULD BE HERE
break;
case MotionEvent.ACTION_UP:
//WHAT CODE SHOULD BE HERE
break;
}
return false;
}
Runnable mAction = new Runnable() {
@Override public void run() {
screen.setImageResource(R.drawable.pic);
}
};
});
}
}