[android-developers] Recognizing Motion Event
i have an application which has the following layout.
a b c d e
f g h i j
and one string,.say str
and i am implementing ontouchlistener and using ontouch(View V,MotionEvent M)
my task is to achieve when a button say 'c' is touched the str set to "down c". it is done by using ACTION_DOWN recognition .
But after that before the ACTION_UP event , if the user slides to 'd' then it should be recognized. and str should set to "b down".
i am not getting by what methods or events i can achieve this. whether i need to use keyevent, hoverevents or touchevents
i am not getting the answer . and i am in a really need of it. i have posted my code. SO someone please give me an idea of how to solve this.
for (int i = 0; i < mybtn.length; i++)
{
String btnid = "btn" + i;
int resid = getResources().getIdentifier(btnid, "id",
getPackageName());
mybtn[i] = (Button) findViewById(resid);
mybtn[i].setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event)
{
// TODO Auto-generated method stub
String s = null;
s = ((Button) v).getText().toString().trim();
switch (event.getAction()) {
// case MotionEvent.ACTION_MOVE:
// Do some stuff
// et.setText("move android"+s, TextView.BufferType.EDITABLE );
// break;
case MotionEvent.ACTION_DOWN:
current = Integer.valueOf(s);
et.setText("down android" + s, TextView.BufferType.EDITABLE);
// Do some stuff
break;
case MotionEvent.ACTION_UP:
et.setText("up android" + s, TextView.BufferType.EDITABLE);
break;
case MotionEvent.ACTION_MOVE:
if (current != Integer.valueOf(s)) {
current = Integer.valueOf(s);
}
break;
}
return false;
}
}
Regards
Kumar Raja--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home