Settings menu does not appear in Android 4.1.1

I have a Google Nexus 7 tablet that runs Android 4.1.1, and I can’t get my application to display the small “three tiny squares in a vertical line” symbol at the bottom right, which indicates that the options menu is available. My 2.3.3-oriented build will display an options menu on other devices (phone 2.3.3 and phone 4.0.3), but not on Nexus 7. To illustrate the problem, I used Eclipse to create "Hello World" as bare-bones , which comes with one menu item "Settings", and also built an example of BluetoothChat from the Android-10 SDK. Barebone does not have a menu symbol, but BluetoothChat. Looking at the code for each, I see no difference in how the menus are handled in relation to construction and inflation, so I hope someone has ideas. Good menu icon: http://i.imgur.com/31Wop.jpg No menu icon: http://i.imgur.com/9Vj3e.jpg

+4
source share
3 answers

Found a problem. In the manifest I had

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15" /> 

Change this setting to

 <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" /> 

The problem is fixed, and now the menu button on the ActionBar appears. The BluetoothChat sample worked because its manifest omitted targetSdkVerion:

 <uses-sdk minSdkVersion="6" /> 
+15
source

From what my test shows, you can stick with both minSdkVersion and targetSdkVersion, even if it is not. So far, the Project Build Target (defined in the project properties) has the same meaning as minSdkVersion. For me, I want to have the old menu in versions 2.2, but the new one (in the title bar) for 3.0 and higher.

 <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> 

In the project properties:

 # Project target. target=android-8 

This seems to work by showing the old options menu below (or using the menu button) on my virtual devices 2.2 and 2.3 and showing a new one on my 3.0, 4.0 and 4.2 virtual and physical devices.

0
source

Do something like this for Android 4.0 and above to display the options menu
. GetWindow () requestFeature (Window.FEATURE_ACTION_BAR);

0
source

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


All Articles