0

here i copied this section of code from a website... and it is not recognizing the symbol R

for eg in statement (R.id.containerView,new TabFragment()).commit(); (R.id.drawerLayout);

public class MainActivity extends AppCompatActivity{
    DrawerLayout mDrawerLayout;
    NavigationView mNavigationView;
    FragmentManager mFragmentManager;
    FragmentTransaction mFragmentTransaction;

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

        /**
         *Setup the DrawerLayout and NavigationView
         */

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        mNavigationView = (NavigationView) findViewById(R.id.shitstuff) ;

        /**
         * Lets inflate the very first fragment
         * Here , we are inflating the TabFragment as the first Fragment
         */

        mFragmentManager = getSupportFragmentManager();
        mFragmentTransaction = mFragmentManager.beginTransaction();
        mFragmentTransaction.replace(R.id.containerView,new TabFragment()).commit();
        /**
         * Setup click events on the Navigation View Items.
         */
SATVIK
  • 11
  • 1
  • 4
  • possible duplicate of [R cannot be resolved - Android error](http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error) – Abhishek Ghosh Aug 29 '15 at 19:58
  • Possible have problem in your XML file. If you can post your layout file as well maybe it will help people to help you – Want2bExpert Aug 29 '15 at 20:32

1 Answers1

0

Make sure everything is placed correctly in your xml files. There should be something like

<DrawerLayout
    android:id="@+id/drawerLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<NavigationView
    android:id="@+id/shitstuff"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

in your xml layout file.

Otherwise, your R file is corrupted somehow. Check this post: "R cannot be resolved to a variable"?

Community
  • 1
  • 1
ryye
  • 315
  • 4
  • 13