By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,789 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,789 IT Pros & Developers. It's quick & easy.

Can i use multiple OnClick() function in one code??

P: 1
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.
Sep 9 '13 #1
Share this Question
Share on Google+
1 Reply


Nepomuk
Expert 2.5K+
P: 3,112
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 setOnClickListener(OnClickListener) function. Look at the first example on the Button api reference, that gives you an idea of how to set OnClickListeners 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. :-)
Sep 9 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.