Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolbar menu item not clickable on android 4.4 (19)

I have a Android app for Android sdk version 23. Now I try to make it available for user using versions 19 to 23. All is working fine expect the toolbar in the head of the app. I can't click an menu item. Nothing happend when I click. Also if I insert Log.v() there is no message in the debug view.

What can I do?

public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        if (id == R.id.action_refresh) {
            doRefreshGames(item);
            return true;
        }

        if(id == R.id.action_rss){
            Intent rssIntent = new Intent(AmericanFootball.this, AmericanFootballRSS.class);
            //if you need to pass data:
            Bundle mBundle = new Bundle();
            mBundle.putString("myKey", "comeon");
            rssIntent.putExtras(mBundle);
            startActivity(rssIntent);
        }

        if (mDrawerToggle.onOptionsItemSelected(item)) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
like image 536
baeckerman83 Avatar asked Apr 05 '16 20:04

baeckerman83


People also ask

How do I access menu items on Android?

Here's a quick example of how to access an Android MenuItem in a Java Activity or Fragment class (i.e., in your Java code). you can access the MenuItem with the id menuItemPinQuote like this in your Android/Java code: public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { menuInflater. inflate(R.

How do I add menu button to my toolbar?

This is going to be in res/menu/main_menu . Right click the res folder and choose New > Android Resource File. Type main_menu for the File name. Choose Menu for the Resource type.


1 Answers

I experienced this issue too. This was because I was using CoordinatorLayout which is a super-powered FrameLayout and thus was Overlaying the toolbar thus blocking interaction with the toolbar. I solved the issue by replacing the CoordinatorLayout with a LinearLayout and giving it a vertical orientation. You can also solve the issue by setting the toolbar position in relation to the parent as described here

like image 105
Esir Kings Avatar answered Oct 01 '22 08:10

Esir Kings