0

I am making an app, and I need to reference a resource file while in the main activity. The path is res/menu/main.xml, how do I do this? Here is the source code.

package com.example.bradenmyers.quikiflipi;

    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.support.v7.widget.PopupMenu;
    import android.view.Menu;
    import android.view.MenuInflater;

    public class MainActivity extends AppCompatActivity {

        private PopupMenu menuInflator;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R(This R is Red).layout.activity_main);
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflator().inflate(R(This R is also Red).menu.main, menu);
            return super.onCreateOptionsMenu(menu);
        }

        private MenuInflater getMenuInflator() {
            return null;
        }
    }
Sait Banazili
  • 1,263
  • 2
  • 12
  • 27
Ethan Reinsch
  • 137
  • 1
  • 10
  • 2
    Clean project should fix the problem for you. – Varundroid Jan 02 '17 at 22:19
  • 1
    (This R is also Red)? It means that you didn't import the framework for it. Click on the 'R', and press alt + enter (Mac) will automatically import it for you. – felixwcf Jan 03 '17 at 03:23

0 Answers0