Why can't Android Studio allow ViewPager symbol?

I am new to Android and I follow the Big Nerd Ranch tutorial. In the book, we create a ViewPager to be able to scroll between list data. For some reason, Android Studio does not recognize ViewPager. See below for the code.

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewPager;

public class CrimePagerActivity extends Activity {
    private ViewPager mViewPager;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
}

I do not know what to do or what might be wrong? Is it somehow related to the Android SDK?

+4
source share
2 answers

Make sure you download the Android support repository using the SDK manager.

Open the build.gradle file and add the support library to the dependency section:

compile 'com.android.support:support-v4:23.0.1'

change your import to this:

import android.support.v4.view.ViewPager;
+4
source

, "testCompile" junit: junit: 4.12 '' , . gradle.

compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
testCompile 'junit:junit:4.12'
0

Source: https://habr.com/ru/post/1607031/


All Articles