Bonjour Mon appli crash je ne comprend pas pourquoi pouvez m’aider svp merci je vous montre mes fichiers java
Class Main
public class MainActivity extends AppCompatActivity
{
Toolbar toolbar;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | TabLayout tabLayout; ViewPager viewPager; ViewPagerAdapter viewPagerAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolBar); setSupportActionBar(toolbar); tabLayout = (TabLayout) findViewById(R.id.tabLayout); viewPager = (ViewPager) findViewById(R.id.viewPager); viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); viewPagerAdapter.addFragments(new HomeFragment(), "Home"); viewPagerAdapter.addFragments(new topFreeFragment(), "Top Free"); viewPagerAdapter.addFragments(new TopPaidFragment(), "Top Paid"); viewPager.setAdapter(viewPagerAdapter); tabLayout.setupWithViewPager(viewPager); } |
}
HOME FRAGMENT
public class HomeFragment extends Fragment {
1 2 3 4 5 6 7 8 9 10 11 | public HomeFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_home, container, false); } |
}
VIEWPAGERADAPTER
public class ViewPagerAdapter extends FragmentPagerAdapter
{
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ArrayList<Fragment> fragments = new ArrayList<>(); ArrayList<String> tabTitles=new ArrayList<>(); public void addFragments(Fragment fragments,String titles){ this.fragments.add(fragments); this.tabTitles.add(titles); } public ViewPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { return fragments.get(position); } @Override public int getCount() { return fragments.size(); } @Override public CharSequence getPageTitle(int position) { return tabTitles.get(position); } |
} TOPFREEFRAGMENT
public class topFreeFragment extends Fragment {
1 2 3 4 5 6 7 8 9 10 11 | public topFreeFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_top_free, container, false); } |
} TOPPAIDFRAGMENTS
1 2 3 4 5 6 7 8 9 10 11 12 13 | public TopPaidFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_top_paid, container, false); } |
}
+0
-0