I'm trying to make a subclass of Button that is better-looking.  It's 
called New_Button.

Right now, I'm trying to make it look different when it is pressed.  I have 
some code that does this, but I suspect
it's not the "right" way to do it.

Can someone tell me if this is the "right" way to draw it differently if 
it's pressed?

boolean my_pressed = false;

public New_Button(Context context, AttributeSet attrs) {
super(context, attrs);
 this.setOnTouchListener(new OnTouchListener() {
 @Override
public boolean onTouch(View v, MotionEvent event) {

if (event.getAction()==MotionEvent.ACTION_DOWN) {
my_pressed=true;
invalidate();
}
 if (event.getAction()==MotionEvent.ACTION_UP) {
my_pressed=false;
invalidate();
}

 return false;
}
});
 
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to