android - Add Event Handler to ImageButton -


i developing android app has imagebutton in it, , need add event handler it. in attempt this, have added new function .java file android studio creates when make new project looks this:

public void tapimagebutton(imagebutton myimgbtn) {       // code stuff come later on. } 

after doing this, trying set onclick proerty not show function, , trying enter manually causes app crash when test it.

'tapimagebutton' function missing

you must have view parameter of method wish call, while bind click event through layout file.

try this:

public void tapimagebutton(view view) {       // code stuff come later on.     toast.maketext(this, "clicked !!", toast.length_short).show(); } 

in xml:

... android:onclick="tapimagebutton" ... 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -