5

I have simple application.

Here is MyActivity.java

public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return super.onCreateOptionsMenu(menu);
    }
}

And I don't really understand why method onCreateOptionsMenu is called on phone and is not called on tablet?

vetalitet
  • 703
  • 2
  • 10
  • 25

3 Answers3

6

If you're using ToolBar:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
    mToolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(mToolbar);
}
Pang
  • 9,564
  • 146
  • 81
  • 122
Golan Shay
  • 1,250
  • 18
  • 15
1

there is concept called ActionBar from API 11, so option menu is not use for tablet version.

check for ActionBar tutorial.. see below link

http://developer.android.com/guide/topics/ui/actionbar.html

AndroUser
  • 572
  • 1
  • 5
  • 10
1

If your activity is extending from Activity class try changing it to AppCompatActivity..

Sathyajith
  • 3,836
  • 3
  • 15
  • 28