Create a custom button
Posted
by
Beppi Menozzi
on Stack Overflow
See other posts from Stack Overflow
or by Beppi Menozzi
Published on 2012-11-26T11:01:42Z
Indexed on
2012/11/26
11:03 UTC
Read the original article
Hit count: 98
android
Sorry if this is too basic. I created a new class that extends Button:
public class MyButton extends Button {
private Context ctx;
public MyButton(Context context) {
super(context);
ctx = context;
}
private void click() {
// DO WHAT I NEED (FOR EXAMPLE CHANGE BACKGROUND)
}
}
How can make it possible that, when I setOnClickListener() from another class where I instantiated this object, the click() method is called automatically? Thanks.
© Stack Overflow or respective owner