Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I decided to create button which I drag it to another button,
So when the button is over it and the mouse or anytouch is released, programmatically check the text of two button.
This code doesn't work.

Java
public boolean onTouch(View v, MotionEvent me) {
// TODO Auto-generated method stub
if (me.getAction() == MotionEvent.ACTION_DOWN){
float oldXvalue = me.getX();
float oldYvalue = me.getY();
Log.i("myTag", "Action UP " + oldXvalue + "," + oldYvalue);
        
}
else if (me.getAction() == MotionEvent.ACTION_UP) {
if ( btn.hasFocus()) {
btn.setFocusableInTouchMode(true);
btn.requestFocus();
btn.setText("Focus");
}
		  
}
else if (me.getAction() == MotionEvent.ACTION_MOVE  ){			
			
LayoutParams params = new LayoutParams(v.getWidth(), v.getHeight(),
 	   (int)(me.getRawX() - (v.getWidth() / 2)), (int)(me.getRawY() - (v.getHeight())));
v.setLayoutParams(params);

}
return true;   
}
});


Please help me...
Posted
Comments
Sergey Alexandrovich Kryukov 31-Aug-13 22:43pm    
Not clear. Note that in "to create button which I drag it to another button" "it" should mean already existing button, otherwise there is nothing to drag. But in this case, what are you going to "create"? Or are there 3 buttons? :-)
—SA
_Sahar 31-Aug-13 23:49pm    
There is 2 button. I want to drag one of them and put on another button, then compare text of them
Please excuse me for talking bad.
Sergey Alexandrovich Kryukov 1-Sep-13 0:24am    
No problem. What do you want to "create then". Or, what do you want to after comparison? In other words, what's the ultimate goal of this activity? And what's your problem?
—SA
_Sahar 1-Sep-13 0:36am    
I have city and center of city,By dargging the button I compare either user is doing right or not.
Sergey Alexandrovich Kryukov 1-Sep-13 2:18am    
Not clear... And why they are represented as buttons? A button should respond to click...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900