2

I'm facing a problem. I am getting the error "Cannot resolve symbol 'activity_main'. I read the other posts about it, and could not figure out how to fix it. Here is my code :

package com.grasland.musicplayer.Activities;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.grasland.musicplayer.R;



public class MainActivity extends AppCompatActivity {

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

        // Get the ViewPager and set it's PagerAdapter so that it can display items
        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        viewPager.setAdapter(new SampleFragmentPagerAdapter(getSupportFragmentManager(),
                MainActivity.this));

        // Give the TabLayout the ViewPager
        TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
        tabLayout.setupWithViewPager(viewPager);
    }
}

There is a screen of my project's tree :

Tree project

Thanks !

Sylvain
  • 113
  • 1
  • 7
  • can you post a screen of your project structure expanding the activity path? It is possible that your activity class is in a different folder, so the resource is not correctly located – magicleon94 Feb 11 '17 at 16:42

1 Answers1

1

Make sure that the name of the main activity's layout file is "activity_main". If its not, rename it to "activity_main". If the name is already correct, try Build → Clean Project.

Iñaki Arango
  • 89
  • 2
  • 8