Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9120439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:37:41+00:00 2026-06-17T05:37:41+00:00

PlaceActivity hosts Two Fragments PlaceDetailsFragment – Which has a view pager – PlaceSlideFragment PlaceMapFramgment

  • 0

PlaceActivity hosts Two Fragments

  1. PlaceDetailsFragment – Which has a view pager – PlaceSlideFragment
  2. PlaceMapFramgment – host Google Maps

When i try to change the orientation the app crashes with the following Error Log.

01-12 15:24:57.950: E/AndroidRuntime(30412): FATAL EXCEPTION: main
01-12 15:24:57.950: E/AndroidRuntime(30412): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m7.nomad/com.m7.nomad.PlaceActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.m7.nomad.fragments.PlaceSlideFragment: make sure class name exists, is public, and has an empty constructor that is public
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3363)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread.access$700(ActivityThread.java:127)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1163)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.os.Looper.loop(Looper.java:137)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread.main(ActivityThread.java:4507)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at java.lang.reflect.Method.invokeNative(Native Method)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at java.lang.reflect.Method.invoke(Method.java:511)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at dalvik.system.NativeStart.main(Native Method)
01-12 15:24:57.950: E/AndroidRuntime(30412): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.m7.nomad.fragments.PlaceSlideFragment: make sure class name exists, is public, and has an empty constructor that is public
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.support.v4.app.Fragment.instantiate(Fragment.java:405)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1767)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:208)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at com.m7.nomad.PlaceActivity.onCreate(PlaceActivity.java:34)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.Activity.performCreate(Activity.java:4465)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
01-12 15:24:57.950: E/AndroidRuntime(30412):    ... 12 more
01-12 15:24:57.950: E/AndroidRuntime(30412): Caused by: java.lang.InstantiationException: can't instantiate class com.m7.nomad.fragments.PlaceSlideFragment; no empty constructor
01-12 15:24:57.950: E/AndroidRuntime(30412):    at java.lang.Class.newInstanceImpl(Native Method)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at java.lang.Class.newInstance(Class.java:1319)
01-12 15:24:57.950: E/AndroidRuntime(30412):    at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
01-12 15:24:57.950: E/AndroidRuntime(30412):    ... 19 more

PlaceSlidesFragemntsAdapter.java

public class PlaceSlidesFragmentAdapter extends FragmentPagerAdapter  {

    DBAdapter db = new DBAdapter(SplashActivity.context);
    List<String> photoList = new ArrayList<String>();

    private int mCount;

    public PlaceSlidesFragmentAdapter(FragmentManager fm) {
        super(fm);

        db.open();
        Cursor photosCursor = db.getPhotos(PlaceActivity.placeId);

        // Iterate Through the Place Cursor
        if (photosCursor.moveToFirst()) {
            do {
                photoList.add(photosCursor.getString(1));
            } while (photosCursor.moveToNext());
        }

        db.close();

        mCount = photoList.size();
    }

    @Override
    public Fragment getItem(int position) {
        return new PlaceSlideFragment(photoList.get(position));
    }

    @Override
    public int getCount() {
        return mCount;
    }

    public void setCount(int count) {
        if (count > 0 && count <= 10) {
            mCount = count;
            notifyDataSetChanged();
        }
    }
}

PlaceSlideFragment.java

public final class PlaceSlideFragment extends Fragment {
    String imageResourceId;

    public PlaceSlideFragment(String i) {
        imageResourceId = i;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        ImageView image = new ImageView(getActivity());

        ImageLoader imgLoader = new ImageLoader(MainActivity.context);
        imgLoader.DisplayImage(imageResourceId, new Activity(), image);

        LinearLayout layout = new LinearLayout(getActivity());
        layout.setLayoutParams(new LayoutParams());

        layout.setGravity(Gravity.CENTER);
        layout.addView(image);

        return layout;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:37:42+00:00Added an answer on June 17, 2026 at 5:37 am

    Your Fragment must have an empty constructor.

    Use setArguments(Bundle) instead of passing parameters to constructor directly.

    In your example in PlaceSlideFragment.java remove constructor. Instead, inside onCreateView use:

    imageResourceId = getArguments().getString("param");
    

    Then, to instantinate PlaceSlideFragment use this code:

    Fragment f = new PlaceSlideFragment();
    Bundle args = new Bundle();
    args.putString("param", yourParam);
    f.setArguments(args);
    

    or it will be even better if you’ll move this code into some static method of PlaceSlideFragment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a Map Activity which has a Fragment which hosts MAPS. All
I have a listview which has a list of places - i have the
I am building an app which looks something like this. It has a action
I'm sure this has been covered but I can't find it anywhere, I basically
Information: My device is a Nexus One with 2.2 and I have tested two
Is Fragment in ViewPager has a equivalent method like OnPageSelected() Or OnPageShow() ? I
I am trying to develop a small app BusTracker which will list down a
I have an application which uses the MediaPlayer to play music. When I play
I am new to android development and I've been creating an application containing two
I have created an Activity which allows a user to create a page. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.