0

ビューページャーで 3 つのフラグメントが使用されています。FragmentPagerAdapter を使用してそれらを切り替えています。私はいつもこのエラーを受け取りますが、その理由がわかりません。

android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment ... make sure class name exists, is public, and has    an empty constructor that is public

これが私の getItem メソッドです。インスタンスを取得するための静的メソッドがありますが、それでも文句を言います。

@Override
public Fragment getItem(int pos) {
  if (SECTION_COUNT > 1){
    switch(pos){
        case RECENT_HISTREES:
            return HistreesFragmentPhone.newInstance(HistreesViewType.Friends, accountId, userId);
        case MY_HISTREES:
            return HistreesFragmentPhone.newInstance(HistreesViewType.All, accountId, userId);
        case DOWNLOADED_HISTREES:
            return HistreesFragmentPhone.newInstance(HistreesViewType.Downloaded, accountId, userId);
    }
  }
   return HistreesFragmentPhone.newInstance(HistreesViewType.All, accountId, userId);
}

これは私の Fragment コンストラクターです。

public static HistreesFragmentPhone newInstance(HistreesViewType viewType, int accountId, int userId) {
    HistreesFragmentPhone f = new HistreesFragmentPhone();

    Bundle args = new Bundle();
    args.putString("viewType", viewType.toString());
    args.putInt("accountId", accountId);
    args.putInt("userId", userId);
    f.setArguments(args);

    return f;
}
4

0 に答える 0