简体   繁体   中英

forced to add android.r and activity_main cannot be resolved

I have downloaded the project from this website: http://www.easyway2in.blogspot.ae/2014/07/android-swipe-views-example.html

Somehow, activity_main cannot be resolved. Whereas my other projects work just fine.

MainActivity.java

package com.swapdemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

public class MainActivity extends FragmentActivity {
    ViewPager viewpager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        viewpager = (ViewPager) findViewById(R.id.pager);
        PagerAdapter padapter = new PagerAdapter(getSupportFragmentManager());
          viewpager.setAdapter(padapter);
    }


}

I have tried importing 'android.R' but that just gets 'activity_main cannot be resolved' message. All I did was add the support for v7-appcompat and nothing more. I have tried cleaning it for countless times. Anyone, help?

确保您导入的是正确的资源, android.R指的是Android资源,您要查找的是“您的项目”的资源,因为这是您的布局文件所在的位置,您的R应该指向com.swapdemo.R

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM