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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:39:43+00:00 2026-06-04T22:39:43+00:00

I have create a sample Fragment application. I have two fragments like list fragment

  • 0

I have create a sample Fragment application.
I have two fragments like list fragment and Detail fragment.
code for fragment class:

public class ListFragment1 extends ListFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
                "Blackberry", "WebOS", "Ubuntu", "Windows7" };
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1, values);
        setListAdapter(adapter);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        String item = (String) getListAdapter().getItem(position);
        DetailFragment fragment = (DetailFragment) getFragmentManager()
                .findFragmentById(R.id.detailFragment);
        if (fragment != null && fragment.isInLayout()) {
            fragment.setText(item);
        } else {
            Intent intent = new Intent(getActivity().getApplicationContext(),
                    DetailActivity.class);
            intent.putExtra("value", item);
            startActivity(intent);

        }

    }
}

Detail fragment class:

public class DetailFragment extends Fragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e("Test", "hello");
    }

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

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.details, container, false);
        return view;
    }

    public void setText(String item) {
        TextView view = (TextView) getView().findViewById(R.id.detailsText);
        view.setText(item);
    }
}

And Activity class
DetailActivity class

public class DetailActivity extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Need to check if Activity has been switched to landscape mode
        // If yes, finished and go back to the start Activity
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            finish();
            return;
        }

        setContentView(R.layout.details_activity_layout);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            String s = extras.getString("value");
            TextView view = (TextView) findViewById(R.id.detailsText);
            view.setText(s);
        }
    }
}

Main Activity class:

public class MyFragmentActivity extends FragmentActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <fragment
        android:id="@+id/listFragment"
        android:layout_width="150dip"
        android:layout_height="wrap_content"
        class="My.fragment.ListFragment1" ></fragment>

    <fragment
        android:id="@+id/detailFragment"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        class="My.fragment.DetailFragment" >
        <!-- Preview: layout=@layout/details -->
    </fragment>

My Logcat trace is..

       05-28 10:42:28.866: W/dalvikvm(484): Unable to resolve superclass of LMy/Fragment/MyFragmentActivity; (21)
05-28 10:42:28.866: W/dalvikvm(484): Link of class 'LMy/Fragment/MyFragmentActivity;' failed
05-28 10:42:28.906: D/AndroidRuntime(484): Shutting down VM
05-28 10:42:28.906: W/dalvikvm(484): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-28 10:42:28.906: E/AndroidRuntime(484): Uncaught handler: thread main exiting due to uncaught exception
05-28 10:42:28.945: E/AndroidRuntime(484): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{My.Fragment/My.Fragment.MyFragmentActivity}: java.lang.ClassNotFoundException: My.Fragment.MyFragmentActivity in loader dalvik.system.PathClassLoader@44e8c748
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.os.Looper.loop(Looper.java:123)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.ActivityThread.main(ActivityThread.java:4363)
05-28 10:42:28.945: E/AndroidRuntime(484):  at java.lang.reflect.Method.invokeNative(Native Method)
05-28 10:42:28.945: E/AndroidRuntime(484):  at java.lang.reflect.Method.invoke(Method.java:521)
05-28 10:42:28.945: E/AndroidRuntime(484):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-28 10:42:28.945: E/AndroidRuntime(484):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-28 10:42:28.945: E/AndroidRuntime(484):  at dalvik.system.NativeStart.main(Native Method)
05-28 10:42:28.945: E/AndroidRuntime(484): Caused by: java.lang.ClassNotFoundException: My.Fragment.MyFragmentActivity in loader dalvik.system.PathClassLoader@44e8c748
05-28 10:42:28.945: E/AndroidRuntime(484):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-28 10:42:28.945: E/AndroidRuntime(484):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-28 10:42:28.945: E/AndroidRuntime(484):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-28 10:42:28.945: E/AndroidRuntime(484):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
05-28 10:42:28.945: E/AndroidRuntime(484):  ... 11 more

My Manifest.xml is

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="My.Fragment"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="MyFragmentActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="DetailActivity"></activity>

    </application>

</manifest>

This is my first fragment program which i get from internet source , On Running this application , I got Runtime excetion some class not found exception.
Please provide me the correct way…

  • 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-04T22:39:44+00:00Added an answer on June 4, 2026 at 10:39 pm

    your package is called My.Fragment in Android Manifest, but in layout you have specified it as My.fragment

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

Sidebar

Related Questions

I have to create an sample code that connect to a socket server, and
I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 (
I have a table with records that look like this: CREATE TABLE sample (
I have a project where I create sample documents. Code here : private void
We have tried to create sample webservices helloworld in Java using Jersey and Tomcat
I have created a sample java socket application. I used Socket s = new
I have created a CPTTradingRangePlot using the up-to-date sample code as an example. The
I have a requirement to create a simple windows forms application that allows an
I have a very simple code where I use Action Bar with tab fragments.
Hi. I have create a background service application following this tutorial http://androidsourcecode.blogspot.com/2010/10/basic-android-background-service.html . But

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.