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

  • Home
  • SEARCH
  • 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 9158713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:18:50+00:00 2026-06-17T13:18:50+00:00

I am working on android fragment when i run my app in android 3.0

  • 0

I am working on android fragment when i run my app in android 3.0 versions and above it’s working fine but when i am trying to run below 3.0 it’s giving forceclose error i am not understanding what is the wrong. Below is log cat errors and my code.

And if run my app in smart phone then i need to display view in another windown with out opening new activity. can you guide me how to do this. And it’s working fine in tablet. I am sending working screen shot for tablet.

01-21 09:29:24.272: E/AndroidRuntime(398): FATAL EXCEPTION: main
01-21 09:29:24.272: E/AndroidRuntime(398): java.lang.NoSuchMethodError: com.example.fragment_demo.MainActivity.getFragmentManager
01-21 09:29:24.272: E/AndroidRuntime(398):  at com.example.fragment_demo.MainActivity.onCreate(MainActivity.java:19)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.os.Looper.loop(Looper.java:123)
01-21 09:29:24.272: E/AndroidRuntime(398):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-21 09:29:24.272: E/AndroidRuntime(398):  at java.lang.reflect.Method.invokeNative(Native Method)
01-21 09:29:24.272: E/AndroidRuntime(398):  at java.lang.reflect.Method.invoke(Method.java:507)
01-21 09:29:24.272: E/AndroidRuntime(398):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-21 09:29:24.272: E/AndroidRuntime(398):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-21 09:29:24.272: E/AndroidRuntime(398):  at dalvik.system.NativeStart.main(Native Method)



public class MainActivity extends Activity { 
    Button b1, b2, b3;   
    @Override   
    public void onCreate(Bundle savedInstanceState)
    {       
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main_fdemo);     
        FragmentManager fm = getFragmentManager();   
        FragmentTransaction ft = fm.beginTransaction();  
        StartFragment sf = new StartFragment();   
        ft.add(R.id.myFragment, sf);     
        ft.commit();      
        b1 = (Button) findViewById(R.id.button1);     
        b2 = (Button) findViewById(R.id.button2);   
        b3 = (Button) findViewById(R.id.button3); 

        b1.setOnClickListener(onButtonClick);  
        b2.setOnClickListener(onButtonClick);  
        b3.setOnClickListener(onButtonClick); 
    }   
    Button.OnClickListener onButtonClick = new Button.OnClickListener(){ 
        @Override    
        public void onClick(View v) 
        {        
            // TODO Auto-generated method stub     
            Fragment fragment = null;     
            if(v == b1){    
                fragment = new Fragment1();   
            }else if(v == b2){     
                fragment = new Fragment2();    
            }else if(v == b3){       
                fragment = new Fragment3();   
            }        
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.replace(R.id.myFragment, fragment);    
            ft.commit();  
        }   
    };

}

main_fdemo.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Fragment 1" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Fragment 2" />

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Fragment 3" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/myFragment"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="3" >
    </LinearLayout>

</LinearLayout>


public class StartFragment extends Fragment
{     
    @Override    
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {      
        // TODO Auto-generated method stub      
        return inflater.inflate(R.layout.start_fragment, container, false); 
    }
}

start_fragment.xml:-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Select the Fragments"
        android:textSize="20dp" />

</LinearLayout>

public class Fragment1 extends Fragment
{     
    @Override    
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {      
        // TODO Auto-generated method stub      
        return inflater.inflate(R.layout.fragment_1, container, false); 
    }
}

fragment_1.xml code:-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F97C7C"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Select the Fragments"
        android:textSize="20dp" />

</LinearLayout>

enter image description here

  • 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-17T13:18:51+00:00Added an answer on June 17, 2026 at 1:18 pm

    You need to use the Android Support Library to be backwards compatible down to API 4. While using the library you will use support methods like getSupportFragmentManager() instead of getFragmentManager().
    http://developer.android.com/training/basics/fragments/support-lib.html

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

Sidebar

Related Questions

I am working on android app and am trying to get fragments working but
I've been trying to get ActionBarSherlock working with Google's fragment tutorial and run into
I'm trying to use setRetainInstance() but it seems not working for me! =(. I
I made an app for tablets that is working just fine on android 3.2.
I'm trying to add a fragment into the Android Settings app to customize the
I am trying to get working my Fragment with ViewPager but I am getting
i am working on android and trying to read a value from my preference
I am working on an android app and using Fragments in UI layouts. In
I am working on my first android app so forgive me if this is
I use android.support.v4.app.FragmentActivity for create a app with multi fragment/panels that can be access

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.