I am taking the Udacity nanodegree program for Android Basics. I am on the Tour Guide App project, which requires a ViewPager, a TabLayout, and Fragments.
When I follow various tutorials and examples, I create a TestAdapter.java class. It begins with this:
package com.example.android.tourguide001;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
public class TestAdapter extends FragmentPagerAdapter {
public TestAdapter(FragmentManager fm) {
super(fm);
}
}
The line "super(fm);" has a line through "super" and the hovertext says that the Fragment Manager is deprecated.
I have tried various imports. I've tried different constructors. I keep reaching an impasse, and it is clear to be that I have a fundamental misunderstanding of how Fragments and Fragment Managers work.
I went to YouTube, found a student who had made a functional Tour Guide App, and got a copy of his code to study. In his Adapter class, He has the same imports as mine, and he has essentially the same code as I have, yet his Fragment Manger is not deprecated.
His code in this case is:
package com.example.tourguideapp;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
public class ViewAdapterPage extends FragmentPagerAdapter {
public ViewAdapterPage(FragmentManager fm)
{
super(fm);
}
}
I cannot figure out what the difference is between his app and mine. Can anyone explain how deprecation errors work, and what might be going on in this case?
EDIT: THANKS FOR THE HELP! THE ANSWER IS...
...in the app build gradle dependencies! Copying mine to his broke his, and copying his to mine fixed mine. So now I get to study the dependencies more.
It feels so much better to have a clue!