Skip to main content
GameDev.net gamedev.net
🔒 Locked

Android app - basic button functionality

Started by Ibzy Oct 27, 2013 at 5:44 PM 1 replies 2k views
Original Post
Ibzy
Ibzy

Hi All,

I am working on an Android app, and am just learning to program on Android. I have experience in a few programming languages, but I'm struggling to combine functionality across xml and java.

Very simple question I'm sure, but how do I make a button activate a function? I have: "public void function(string a, string b)" with the function inside in Java, and on the xml layout I have

SimonForsman
SimonForsman

IIRC you have to specify a method that takes a View as its only parameter in the XML file.

so your method should be:

public void someMethod(View v) {

...code

}

and then in the xml layout:

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Ibzy
Ibzy

Hi Simon,

Thanks for this - pointed me in the right direction. Didn't quite realise how 'separated' the code needed to be.

Cheers

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.