Java – binding methods to buttons in Android
•
Java
There is a button in my layout, which contains the following attributes: Android: onclick = "nextq". In my java code, there are the following methods:
public int nextQ() { // do stuff here return answer; }
The answer is an integer Just click this button and the application will close Do you know why it breaks?
Solution
If you have Android: onclick = "nextq", your context (usually your activity) must have a method that signs public void nextq (view view) See docs on the onclick attribute
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码