When converting Activity to AppCompatActivity why is there no menu.main, and how do I replace it?

By J. Doe

Please understand that I am so new to Android programming that I am often lost. I need to understand the basics. I am following a tutorial https://www.youtube.com/watch?v=5sEeprYnHa8 and want to do it using the AppCompatActivity instead of the older Activity. I want to inflate the menu, although I have no idea why menu is not automatically in the res folder. It cannot resolve the symbol menu_mail.xml What exactly should I do in this situation? What is going on? Thanks.

package com.example.android.cameraattempt;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
private Button mRecordView, mPlayView;
private VideoView mVideoView;
private int ACTIVITY_START_CAMERA_APP = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRecordView = (Button)findViewById(R.id.PlayButton);
    mPlayView = (Button)findViewById(R.id.RecordButton);
    mVideoView = (VideoView)findViewById(R.id.videoView2);
    mRecordView.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent callAppVideoIntent = new Intent();
            callAppVideoIntent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);
            startActivityForResult(callAppVideoIntent, ACTIVITY_START_CAMERA_APP );
        }
    });
    mPlayView.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            mVideoView.start();
        }
    });
}
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    if(requestCode == ACTIVITY_START_CAMERA_APP && resultCode == RESULT_OK){
        Uri videoURI = data.getData();
        mVideoView.setVideoURI(videoURI);
    }
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
    getMenuInflater().inflate(R.menu_main, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
    int id = item.getItemId();
    int action_settings = 0;
    if(id == action_settings){
        return true;
    }
    return super.onOptionsItemSelected(item);
}
}

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273