i am making an android app .I am just a beginner. can someone tell me if i can use more than one OnClick() in my code. As i need to perform specific tasks on each button click.
Can i use multiple OnClick() function in one code??
Collapse
X
-
Hello Aradhya and welcome to bytes.com!
In Android programming, every button (in fact everything that extends a View) can have an OnClickListener which you can set with the setOnClickListe ner(OnClickList ener) function. Look at the first example on the Button api reference, that gives you an idea of how to set OnClickListener s via Java or the second and third code blocks for how to set one via XML. So yes, you can have many, many OnClick methods. :-)
Comment