سؤال

i'm using actionbarsherlock and i declared my menu in actionbar.xml in the menu folder. here's the content of actionbar.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@+id/abSearch" android:showAsAction="always" android:icon="@drawable/search_orange"></item>
</menu>

now i tried to implement onOptionsItemSelected and here's what I did:

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.abSearch:
            Intent intent = new Intent(this, SearchRecipes.class);
            startActivity(intent);
            return true;

        }
    }

but the problem is eclipse says abSearch cannot be resolved. I tried cleaning the projects many times but to no avail.

هل كانت مفيدة؟

المحلول

Replace:

android.R.id.abSearch

With:

R.id.abSearch
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top