First of all, English is not my first language but I will try my best. I'm new to Android. How to discover three or four touch buttons with one finger or one touch as shown in the picture?
I created RelativeLayout containing buttons, @Override onTouch Listener(). I read on Android but I could not understand how it was done. I need a concrete example to understand how touch events are taken from a set of buttons at once.
public class MainActivity extends Activity implements OnTouchListener {
Button button1,button2,button3,button4,
button5,button6,button7,button8,button9;
RelativeLayout relative;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 =(Button)findViewById(R.id.b1);
button2 =(Button)findViewById(R.id.b2);
button3 =(Button)findViewById(R.id.b3);
button4 =(Button)findViewById(R.id.b4);
button5 =(Button)findViewById(R.id.b5);
button6 =(Button)findViewById(R.id.b6);
button7 =(Button)findViewById(R.id.b7);
button8 =(Button)findViewById(R.id.b8);
button9 =(Button)findViewById(R.id.b9);
relative = (RelativeLayout)findViewById(R.id.re);
button1.setOnTouchListener(this);
button2.setOnTouchListener(this);
button3.setOnTouchListener(this);
button4.setOnTouchListener(this);
button5.setOnTouchListener(this);
button6.setOnTouchListener(this);
button7.setOnTouchListener(this);
button8.setOnTouchListener(this);
button9.setOnTouchListener(this);
relative.setOnTouchListener(this);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
//How to find out that touch was done from button13 to button9
break;
case MotionEvent.ACTION_UP:
break;
}
return true;
}
}