boolean flag = true;
......
imageButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if (flag)
{
imageButton.setImageResource(R.drawable.ic_alarm_on1);
alarm();}
else {
imageButton.setImageResource(R.drawable.ic_alarm_on);
alarmoff();}
flag = !flag;
}
});