0

I am animating an action button:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);

    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ImageView iv = (ImageView)inflater.inflate(R.layout.iv_main_menu_icon, null);
    Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotate);
    rotation.setRepeatCount(Animation.INFINITE);
    iv.startAnimation(rotation);
    menu.findItem(R.id.action_goto_menu).setActionView(iv);
    return super.onCreateOptionsMenu(menu);
}

But the problem is, after applying this animation the click event isn't firing from this. What am I missing?

A. K. M. Tariqul Islam
  • 2,824
  • 6
  • 31
  • 48

1 Answers1

0

I think you should put that code inside

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {

default:
    return super.onOptionsItemSelected(item);
}
}

not inside

onCreateOptionsMenu()
Clint Paul
  • 313
  • 2
  • 6
  • 18