我正在尝试将一个viewpager放在一个自定义对话框中(wasabeef的blurdialogfragment),但是,我不知道问题,或者如何替换它,因为它说:“无法解析方法getSupportFragmentManager()”
如果有人可以帮我这个,我会很感激..
代码:
public class DialogHelperForNoobs extends BlurDialogFragment {
String personName;
String personGivenName;
String personFamilyName;
String personEmail;
String personId;
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
public DialogHelperForNoobs() {
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return createDialogHelperForNoobs();
}
public AlertDialog createDialogHelperForNoobs() {
Bundle mArgs = getArguments();
//Datos Usuario
personName = mArgs.getString("personName");
personGivenName = mArgs.getString("personGivenName");
personFamilyName = mArgs.getString("personFamilyName");
personEmail = mArgs.getString("personEmail");
personId = mArgs.getString("personId");
//INFLADOR DIALOGO
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View v = inflater.inflate(R.layout.activity_dialog_helper_for_noobs, null);
//Error in FragmentManager getSupportFragmentManager()
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) v.findViewById(R.id.ViewPager);
mViewPager.setAdapter(mSectionsPagerAdapter);
builder.setView(v);
return builder.create();
}
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_view_pager_noobs, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "SECTION 1";
case 1:
return "SECTION 2";
case 2:
return "SECTION 3";
}
return null;
}
}
}
任何人都可以提供帮助?感谢。
答案 0 :(得分:0)
取决于你从哪里调用它,但我怀疑是因为getSupportFragmentManager
类AppCompatActivity
上的Firstname = input("Firstname: ")
Lastname = input("Lastname: ")
Form = input("Form: ")
Phone = input("Phone: ")
Address = input("Address: ")
date= input("Date of birth: ")
gender = input("Gender: ")
email = input("Email: ")
c.execute("INSERT INTO Students(Firstname,Lastname,Form,Phone,Address,Date_of_birth,Gender,email) VALUES('{}','{}','{}','{}','{}','{}','{}','{}')".format(Firstname,Lastname,Form,Phone,Address,date,gender,email))
print(Firstname,Lastname,"Has been added to the database")