Friday, 15 February 2013

android - Simple way to get which image was clicked when running same function -



android - Simple way to get which image was clicked when running same function -

i'm making card game android. select first card clicking image1, sec card clicking image2, etc. these images run same function in java, how can pass variable clicked image1, image2, or image3? i'd avoid having 3 functions exact same aside 1 variable. input.

i'm not sure mean "images run same function in java", if mean have same onclicklistener utilize getid() determine view clicked.

public void onclick(view v) { switch(v.getid()) { case r.id.one: // break; case r.id.two: // break; } }

android

No comments:

Post a Comment