what is onclicklistener in android code example

Example 1: onclicklistener in android studio

Name.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(MainActivity.this,FileName.class));
            }
        });

Example 2: onclick listener android

Button myButton;
awesomeButton = new Button(this);
awesomeButton.setOnClickListener(new View.OnClickListener() {
	@Override
    public void onClick(View v) {
    	startActivity(new Intent(MainActivity.this,NewActivity.class));
    });
}

Example 3: onclick method android

public void clickFunction (View view){}

Tags:

Misc Example