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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:55:47+00:00 2026-05-29T05:55:47+00:00

Using fragments for the first time. As fragment in itself an activity, going by

  • 0

Using fragments for the first time. As fragment in itself an activity, going by the documentation, I think I’ve written it correctly in the manifest.xml.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/example_fragment"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment class="com.test.methods.ExampleFragment"
            android:id="@+id/list"
            android:layout_weight="1"
            android:layout_width="0px"
            android:layout_height="match_parent" />

    <FrameLayout android:id="@+id/details" android:layout_weight="1"
            android:layout_width="0px"
            android:layout_height="match_parent" />

</LinearLayout>

My fragment:

package com.test.methods;

import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.crumbin.main.R;

public class ExampleFragment extends ListFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        setListAdapter(new ArrayAdapter<String>(getActivity(),
                R.id.list,
                Shakespeare.TITLES));
        return inflater.inflate(R.layout.example_fragment, container, false);
    }
}

My Activity:

package com.test.methods;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class DemoUserActivity extends FragmentActivity{
    protected void OnCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        if (savedInstanceState == null)
        {
            ExampleFragment details = new ExampleFragment();
            details.setArguments(getIntent().getExtras());
            getSupportFragmentManager().beginTransaction().add(
                    android.R.id.content,details).commit();
        }

    }
}

My intent:

intent = new Intent().setClass(this, DemoUserActivity.class);
spec = tabHost.newTabSpec("list").setIndicator("FragmentTest",
                  res.getDrawable(R.drawable.icon_list_tab))
              .setContent(intent);
tabHost.addTab(spec);

I get no output out of this. I tried debugging but it is not even reaching my activity file.

  • 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-05-29T05:55:50+00:00Added an answer on May 29, 2026 at 5:55 am

    No Activity is different thing, and Fragment is different, you can use these to create your application moduler, and replace one with another with minimum efforts, but can not use as a replacement of other, if You want to use a fragment, you need to declare an activity, in that activity you need to add your fragment, individual fragment without Activity can not be used.

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

Sidebar

Related Questions

It is my first time using android fragment. I am following this tutorial to
This is my first time using fragments in general so bear with me. I
I am trying out using fragments with my tabhost for the first time and
I'm drawing lots of GL_LINES primitives, shading them using vertex and fragment shaders written
I intrecept server's response using xml,xsl and extract required fragments, to extract html fragments
In one of my project i am using 2 fragments.one fragment is displaying a
I know that when you're first instantiating a fragment you can pass arguments using
I'm using fragments and when I select something on my left fragment, I want
Below are two fragments (ready to compile) of code. In first fragment in which
I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it

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.