Android OnTouch listener easy question?

Another way could be to add the buttons using code instead of XML However, just to clean up that code int buttonIds = new int{R.id. Cmd_main1, R.id. Cmd_main2}; // and so on for(int buttonId : buttonIds) { Button be = (Button)findViewById(buttonId); b.

SetOnTouchListener(tListener1); } Also, an onClickListener is probably cleaner, depending on what you want the buttons to do. You could then also specify the onClickListener in XML: Button android:onClick="myClickHandler and in the activity, add the corresponding method: class MyActivity extends Activity { public void myClickHandler(View target) { // Do stuff } }.

Another way could be to add the buttons using code instead of XML. However, just to clean up that code... int buttonIds = new int{R.id. Cmd_main1, R.id.

Cmd_main2}; // and so on for(int buttonId : buttonIds) { Button be = (Button)findViewById(buttonId); b. SetOnTouchListener(tListener1); } Also, an onClickListener is probably cleaner, depending on what you want the buttons to do. You could then also specify the onClickListener in XML: and in the activity, add the corresponding method: class MyActivity extends Activity { public void myClickHandler(View target) { // Do stuff } }.

– Henzl0l Feb 17 at 21:55 @Henzl0l I think that depends on what you're making. The fact that their names are just indexed by numbers may indicate that. Also, an onClickListener could be preferrable -- will post another answer to highlight code.

– Arve Feb 17 at 22:13 I'm using on touch for a reason, I need the buttons to react the moment they're touched. I'm still new to android, so I'm not sure if there's a better method of doing so. – Henzl0l Feb 17 at 22:19 onclick?

That should also work – kantu Feb 170 at 11:04.

To capture the touch events a call to setOnTouchListener(OnTouchListener) has to be made to set the listner instance that will handle the events. Listener is the view itself and it is hooked up in the constructor. The view is initialized with a Bitmap which is the image that will be manipulated using the touch events.

Is used to make sure the image is rendered with the correct translation (or position), rotation and scale.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions