MuM6oJuM6o
MuM6oJuM6o

Reputation: 107

onOptionItemsSelected not called

I've added menu items to the overflow area of the action bar programatically. I've created the onOptionsItemsSelected method as well. Yet, when I click on the options in the overflow menu, I get the following errors:-

I/ListPopupWindow: Could not find method setEpicenterBounds(Rect) on PopupWindow. Oh well. 03-19 05:49:33.907 18143-18143/com.cs478.arjan.a3 W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 03-19 05:49:34.876 18143-18143/com.cs478.arjan.a3 I/Choreographer: Skipped 49 frames! The application may be doing too much work on its main thread. 03-19 05:51:00.461 1258-1577/? D/hwcomposer: hw_composer sent 216 syncs in 119s 03-19 05:51:55.146 3080-3086/com.cs478.arjan.a2 W/art: Suspending all threads took: 35.702ms

I've defined my class as :-

public class Basketball extends AppCompatActivity implements ListSelectionListener {
    private android.app.ActionBar a;
...
 public boolean onCreateOptionsMenu(Menu menu){
        menu.add(Menu.NONE, 1, Menu.NONE, "Baseball");
         return true;
    }
    public boolean onOptionsItemsSelected(MenuItem item){
        Log.i("project III",TAG+" in optionsItems Selected");
        switch (item.getItemId()){
            case 1:
                Intent intent = new Intent(Basketball.this,Baseball.class);
                startActivity(intent);
                break;
        }
        return true;
    }
...
}

Any suggestions to resolve this issue will be highly appreciated.

Regards Arjan

Upvotes: 0

Views: 2426

Answers (2)

taman neupane
taman neupane

Reputation: 938

I think @override is missing in this case android won't call it.please check it.

Upvotes: 1

Jaydeep Devda
Jaydeep Devda

Reputation: 735

write override over methods:

    public class Basketball extends AppCompatActivity implements ListSelectionListener {
    private android.app.ActionBar a;
...
     @Override
     public boolean onCreateOptionsMenu(Menu menu){
        menu.add(Menu.NONE, 1, Menu.NONE, "Baseball");
         return true;
    }
    @Override
    public boolean onOptionsItemsSelected(MenuItem item){
        Log.i("project III",TAG+" in optionsItems Selected");
        switch (item.getItemId()){
            case 1:
                Intent intent = new Intent(Basketball.this,Baseball.class);
                startActivity(intent);
                break;
        }
        return true;
    }
...
}

Upvotes: 1

Related Questions