I'm new to Android and I'm following the Big Nerd Ranch Guide. In the book we are creating a ViewPager to be able to swipe between list-details. For some reason Android Studio doesn't recognise the ViewPager. Look 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 don't know what to do or what could be wrong? Has this something to do with the Android SDK?
This function is deprecated.
Android ViewPager widget is found in the support library and it allows the user to swipe left or right to see an entirely new screen. Today we're implementing a ViewPager by using Views and PagerAdapter. Though we can implement the same using Fragments too, but we'll discuss that in a later tutorial.
ViewPager in Android is a class that allows the user to flip left and right through pages of data. This class provides the functionality to flip pages in app. It is a widget found in the support library. To use it you'll have to put the element inside your XML layout file that'll contain multiple child views.
Make sure you have downloaded the Android Support Repository using the SDK Manager.
Open the build.gradle file and Add the support library to the dependencies section:
compile 'com.android.support:support-v4:23.0.1'
change your import to this:
import android.support.v4.view.ViewPager;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With