how to use button without declaring? code example

Example 1: android studio button usage

//this for xml file 

Example 2: show button selected when clicked

mycodes_Button.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        mycodes_Button.setPressed(true);
        return true;
    }
});

Tags:

Misc Example