Thursday, 17 September 2015

setting up onclick method

declaring a single onClick function for all instead of using all anonymous   innerClass stuff

first we need to implements View.OnClickListener

then in the onClick funtion which recives View as parameter
we need to setup swich Case to know which element has been clicked
so in the the switch case we need to write

switch(view.getId())
{
case R.id.b1: .......;break;
case R.id.b2: .......;break;
}

and in the setOnClickListener thing insead on declaring whole view.onclicklistener
just type (this)

No comments:

Post a Comment