Answers for "android android:onclick"

0

onclick android

//declare and define the button
Button button = (Button) findViewById(R.id.button1);




//method 1: set the onclick eventlistener with java only
button.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
    // TODO Auto-generated method stub
  }
 });
/////




//method 2:use also layout code (xml)

//xml:
//add the following :
android:onClick="functionName"
//to the view you want to add the eventlistener to 
  
//java: add to the main class
  public void functionName(View v) {

}
Posted by: Guest on March-04-2022
3

onclick method android

public void clickFunction (View view){}
Posted by: Guest on October-04-2020

Code answers related to "android android:onclick"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language