Pages

August 29, 2010

Android Tips : onClickListener:onClick()


In this post , we will learn "Easy/Effective way to write code in onClickListener's onClick() to know which Button is clicked"

Inside onClick(View view) : write a switch-case as shown in below code.
switch(view.getId())
{
    case R.id.Button_Save:
       //Button Save clicked.
       //some stuff 
       break;

     case R.id.Button_Edit:
       //Button Edit clicked.
       //some stuff 
       break;
} 

No comments:

Post a Comment