Page 198 - MDP2022-2
P. 198
}
}
private static class ScreenSlidePagerAdapter extends FragmentStateAdapter {
private static final int NUM_PAGES = 3;
public ScreenSlidePagerAdapter(@NonNull FragmentActivity fragmentActivity) {
super(fragmentActivity);
}
@NonNull
@Override
public Fragment createFragment(int position) {
switch (position) {
case 0:
return new HomeFragment();
case 1:
return new ListFragment();
case 2:
return new SettingFragment();
}
return new HomeFragment();
}
@Override
public int getItemCount() {
return NUM_PAGES;
}
}
}
package com.headthings.mdp_project_2022.mainFragment;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;