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 8016977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:41:53+00:00 2026-06-04T20:41:53+00:00

I have created one application in that I need two fragment, So i declared

  • 0

I have created one application in that I need two fragment, So i declared One fragment class and inside that class i created another static fragment class. i altered main.xml as

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
             android:layout_width="fill_parent"
             android:layout_height="fill_parent">
    <fragment
        android:id="@+id/titles"
        android:layout_width="25dp"
        android:layout_height="wrap_content"
        class="frag.demo.DActivity$TFragment" />

    <fragment
        android:id="@+id/details"
        android:layout_width="25dp"
        android:layout_height="wrap_content"
        class="frag.demo.DActivity$DFragment" />

</FrameLayout>

On running this application , I got runtime exception like

05-25 14:39:45.224: E/AndroidRuntime(911): Uncaught handler: thread main exiting due to uncaught exception
05-25 14:39:45.264: E/AndroidRuntime(911): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{frag.demo/frag.demo.JFragmentActivity}: java.lang.ClassNotFoundException: frag.demo.JFragmentActivity in loader dalvik.system.PathClassLoader@44e8c6f0
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.os.Looper.loop(Looper.java:123)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.ActivityThread.main(ActivityThread.java:4363)
05-25 14:39:45.264: E/AndroidRuntime(911):  at java.lang.reflect.Method.invokeNative(Native Method)
05-25 14:39:45.264: E/AndroidRuntime(911):  at java.lang.reflect.Method.invoke(Method.java:521)
05-25 14:39:45.264: E/AndroidRuntime(911):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-25 14:39:45.264: E/AndroidRuntime(911):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-25 14:39:45.264: E/AndroidRuntime(911):  at dalvik.system.NativeStart.main(Native Method)
05-25 14:39:45.264: E/AndroidRuntime(911): Caused by: java.lang.ClassNotFoundException: frag.demo.JFragmentActivity in loader dalvik.system.PathClassLoader@44e8c6f0
05-25 14:39:45.264: E/AndroidRuntime(911):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-25 14:39:45.264: E/AndroidRuntime(911):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-25 14:39:45.264: E/AndroidRuntime(911):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-25 14:39:45.264: E/AndroidRuntime(911):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)

05-25 14:39:45.264: E/AndroidRuntime(911): … 11 more

And My JFragmentActivity class extends FragmentActivity.
So please provide me where the code goes wrong…

My Activity class

public class DActivity extends FragmentActivity {// from android.support.v4.app.*;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       Log.i("DA","active");
        if (getResources().getConfiguration().orientation
                == Configuration.ORIENTATION_LANDSCAPE) {
            // If the screen is now in landscape mode, we can show the
            // dialog in-line with the list so we don't need this activity.
            finish();
            return;
        }

        if (savedInstanceState == null) {
            // During initial setup, plug in the details fragment.
            DFragment details = new DFragment();
            details.setArguments(getIntent().getExtras());
            getSupportFragmentManager().beginTransaction().add(android.R.id.content, details).commit();
        }
    }
    public static class TFragment extends ListFragment {
        boolean mDualPane;
        int mCurCheckPosition = 0;
        String nos[]={"1","2","3","4","5"};
        public TFragment(){

        }
        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onActivityCreated(savedInstanceState);
            Log.i("TF","active");
            setListAdapter(new ArrayAdapter<String>(getActivity(),R.layout.simple_list,nos));
            View detailsFrame = getActivity().findViewById(R.id.nos);
            mDualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
            if (savedInstanceState != null) {
                // Restore last state for checked position.
                mCurCheckPosition = savedInstanceState.getInt("curChoice", 0);
            }
             if (mDualPane) {
                    // In dual-pane mode, the list view highlights the selected item.
                    getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
                    // Make sure our UI is in the correct state.
                    showDetails(mCurCheckPosition);
                }
        }
         @Override
            public void onSaveInstanceState(Bundle outState) {
                super.onSaveInstanceState(outState);
                outState.putInt("curChoice", mCurCheckPosition);
            }
         @Override
            public void onListItemClick(ListView l, View v, int position, long id) {
                showDetails(position);
            }
         void showDetails(int index) {
                mCurCheckPosition = index;

                if (mDualPane) {
                    // We can display everything in-place with fragments, so update
                    // the list to highlight the selected item and show the data.
                    getListView().setItemChecked(index, true);

                    // Check what fragment is currently shown, replace if needed.
                    DFragment details = (DFragment)
                            getFragmentManager().findFragmentById(R.id.nos);
                    if (details == null || details.getShownIndex() != index) {
                        // Make new fragment to show this selection.
                        details = DFragment.newInstance(index);

                        // Execute a transaction, replacing any existing fragment
                        // with this one inside the frame.
                        FragmentTransaction ft = getFragmentManager().beginTransaction();
                        ft.replace(R.id.nos, details);
                        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
                        ft.commit();
                    }

                } else {
                    // Otherwise we need to launch a new activity to display
                    // the dialog fragment with selected text.
                    Intent intent = new Intent();
                    intent.setClass(getActivity(), DActivity.class);
                    intent.putExtra("index", index);
                    startActivity(intent);
                }
            }


    }
    public static class DFragment extends Fragment {
        String names[]={"aaa","bbb","ccc","ddd","eee"};
        public DFragment() {
            // TODO Auto-generated constructor stub
        }
    public static DFragment newInstance(int index){
        DFragment f= new DFragment();
        Bundle args=new Bundle();
        args.putInt("index", index);
        f.setArguments(args);
        return f;
    }
    public int getShownIndex() {
        return getArguments().getInt("index", 0);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        Log.i("DF","active");
        if (container == null) {
            return null;
        }
         ScrollView scroller = new ScrollView(getActivity());
         TextView text = new TextView(getActivity());
         int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                 4, getActivity().getResources().getDisplayMetrics());
         text.setPadding(padding, padding, padding, padding);
         scroller.addView(text);
         text.setText(names[getShownIndex()]);
         return scroller;
    }

    }
}

And My main activity class is

public class JFragmentActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("main","active");
        setContentView(R.layout.main);
        /*Intent i = new Intent(getApplicationContext(), DActivity.class);
        startActivity(i);*/
    }
}
  • 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-04T20:41:55+00:00Added an answer on June 4, 2026 at 8:41 pm

    If the second fragment is inside the first one then the class attribute of second fragment should be like:

    class="frag.demo.TFragment$DFragment"
    

    Thank you 🙂

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

Sidebar

Related Questions

I have created one application in flex that is accessing the Java webservice using
I have created one application in j2me, I have used json parsing in that
i have created an mvc3 web application that uses forms based authentication. one part
I have created two forms in my Windows Application. One Form acts as a
All of my cross-platform libraries are created with solutions that have two projects: one
Hi I have created a simple Main application and two InjectedApplications (InjectedApplication1 and InjectedApplication2)
I have created one MVC3 application. In which I'm selecting two Ids from two
I have created one Catalyst application and I have created Schema and Model using
hello i have created one windows application in c# .net and its working fine
I have created one dynamic button in my application and I call the following

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.