Question

I have this Activity that extends the SherlockFragmentActivity. I also use AndroidAnnotations 3 and i used the @Click feature in another Activity (it works).

This is the working onCreateOptionsMenu

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.profile_menu, menu);
    return super.onCreateOptionsMenu(menu);
}

This is the onClickAction never fired

@Click
public void logoutButton() {
    Log.i("debug", "ok, i'm here");
}

This is the related res/xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/logoutButton"
        android:title="logout"
        android:showAsAction="always" />
</menu>

As i said, when i touch the logoutButton it doesn't fire the event (or it doesn't catch it). Any idea? There's something wrong?

Était-ce utile?

La solution

Oh, dear: it's @OptionsItem for ActionBar items, not @Click.

That's all.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top