Toolbar menu item that cannot be clicked on android 4.4 (19)

I have an Android application for Android sdk version 23. Now I'm trying to make it available to users using versions 19 to 23. Everything works fine, we expect the toolbar to be in the main application window. I can not click a menu item. When I click, nothing happens. 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); } 
+5
source share
1 answer

I also had this problem. This was due to the fact that I used the CoordinatorLayout , which is a super-powerful FrameLayout and thus was an overlap of the toolbar, thereby blocking interaction with the toolbar. I solved the problem by replacing the CoordinatorLayout with a LinearLayout and giving it a vertical orientation. You can also solve the problem by setting the position of the toolbar in relation to the parent, as described here

0
source

Source: https://habr.com/ru/post/1246503/


All Articles