I'm developing a weather app, but I have a problem when displaying an optionsMenu with some smartphones. I want to display a menu with 3 options, but on the HTC one X, only 2 options are displayed.
The problem is that the black bar at the bottom of the screen hides the third option of my menu.
Here is a screenshot of the problem : (we should see "Recharger", "Voir cette image" and the last option : "Autres cartes")
The code :
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0,100,0,m_res.getStringArray(R.array.menu_reload)[Commons.currentLanguage]).setIcon(R.drawable.reload);
menu.add(0,101,0,m_res.getStringArray(R.array.menu_view_single)[Commons.currentLanguage]).setIcon(R.drawable.see);
if(m_model.getUrl2().size() !=0)
menu.add(0,102,0,m_res.getStringArray(R.array.menu_more)[Commons.currentLanguage]).setIcon(R.drawable.more);
SubMenu moreMaps = menu.addSubMenu(0,103,0,m_res.getStringArray(R.array.menu_others_maps)[Commons.currentLanguage]).setIcon(R.drawable.france);
if(m_time == 1)
{
for(int iBoucle = 0 ; iBoucle < m_model.getNames1().size() ; iBoucle++)
moreMaps.add(1,iBoucle,1,m_model.getNames1().get(iBoucle));
}
else
{
for(int iBoucle = 0 ; iBoucle < m_model.getNames2().size() ; iBoucle++)
moreMaps.add(1,iBoucle,1,m_model.getNames2().get(iBoucle));
}
onContextItemSelected(moreMaps.getItem());
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 100:
if(Commons.getNetworkState() || Commons.getWifiState())
{
eraseData();
loadingData();
}
else
Commons.getConnectivityErrorMessage(m_Context);
return true;
case 101:
Intent sia = new Intent(m_Context, SingleImageActivity.class);
sia.putExtra("url", correctURL(m_urlImages.get(m_step)));
sia.putExtra("choiceNumber", -1);
if(m_textIsHour)
{
if(m_time == 1)
sia.putExtra("title", m_model.getNames1().get(m_mode)+" - "+m_model.getHours1().get(m_step)+"h");
else
sia.putExtra("title", m_model.getNames2().get(m_mode)+" - "+m_model.getHours2().get(m_step)+"h");
}
startActivity(sia);
break;
case 102:
if(Commons.getNetworkState() || Commons.getWifiState())
{
Intent modelSubList = new Intent(m_Context, ModelViewActivity.class);
modelSubList.putExtra("model",m_modelNumber);
modelSubList.putExtra("mode",m_mode);
if(m_time == 1)
modelSubList.putExtra("time",2);
else
modelSubList.putExtra("time",1);
startActivity(modelSubList);
finish();
}
else
{
Commons.getConnectivityErrorMessage(m_Context);
}
break;
case 103:
break;
default:
if(Commons.getNetworkState() || Commons.getWifiState())
{
Intent otherMapsIntent = new Intent(m_Context, ModelViewActivity.class);
otherMapsIntent.putExtra("model",m_modelNumber);
otherMapsIntent.putExtra("mode",item.getItemId());
otherMapsIntent.putExtra("time",m_time);
startActivity(otherMapsIntent);
finish();
return true;
}
else
{
Commons.getConnectivityErrorMessage(m_Context);
return false;
}
}
return false;
}
This code is showing three menu options on the US and European One X phones I have here: https://github.com/lnanek/Misc/tree/master/OneXFullscreenMenuTest
Can you try it on your device? If it doesn't work, then we know it is the software on your device. If it does work, then it could be something in your code.
Can you post more about your situation? I'm particularly interested in the code for how you turn on fullscreen and your AndroidManifest.xml (for things like the uses-sdk line and theme settings).
I don't see anything wrong offhand in the code you posted, but could you comment out this line just for a quick check?
if(m_model.getUrl2().size() !=0)
If that check isn't passing, then there should be only two menu items, not three. So commenting it out would be a quick check (or watching in a debugger to see if all three adds are called, of course).
Please note that onCreateOptionsMenu is only called the very first time the Activity instance shows the options menu, as opposed to onPrepareOptionsMenu which is called every time. So if adding that third menu option is not done the very first time, then it never will be.