I\'ve started working on an app. I build the menu yesterday but the onClick method doesn\'t work! I created a class that extends View and called her MainMenuObject - that cl
You have to call setOnClickListener(this)
in contructor(s) and implement View.OnClickListener
on self.
public class MyView extends View implements View.OnClickListener {
public MyView(Context context) {
super(context);
setOnClickListener(this);
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
setOnClickListener(this);
}
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "On click.", Toast.LENGTH_SHORT).show();
}
}