Home > Mobile >  Tablayout Viewpager and Viewpager2 problem
Tablayout Viewpager and Viewpager2 problem

Time:10-28

Hello everyone, I am now in learning android with B site video learning to write a few small projects, I encountered a few problems here:
1, I don't know why I can't find the viewpager android studio, only viewpager2, practice before their own time do not have this problem has been with the viewpager, for yourself or a novice, so watching online viewpager2 and tablayout linkage or can understand half don't know their practical applications, how can I get viewpager out afresh,
2:
The import android. App. Fragments;

The import androidx. The annotation. NonNull;

The import androidx. Lifecycle. Lifecycle;
The import androidx. Viewpager2. Adapter. FragmentStateAdapter;

The import com. Example. Taobaounion. Base. BaseFragment;

Public class HPagerAdapter extends FragmentStateAdapter {


@ NonNull
@ Override
Public androidx. Fragments. App. Fragments createFragment (int position) {
return null;
}

@ Override
Public int getItemCount () {
return 0;
}
}
This is the problem when I want to write viewpager2 adapter, I don't know why inherit FragmentStateAdapter rewrite method is appear the results, androidx. Fragments. The app. The fragment and fragments manager also can not find, appear error, this is probably where a problem excuse me? Before contact, didn't the two problems, don't know if the result of the update or what the reason, hope bosses can help solve, thank you very much!

CodePudding user response:

Why can't find viewpage? Viewpage androidx address is androidx. Viewpager. Widget. The viewpager, you FragmentStateAdapter then what's the problem?

CodePudding user response:

Have you introduced a v4 package?
  • Related