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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:35:06+00:00 2026-05-26T21:35:06+00:00

I just started with fragment design for HoneyComb. I created two fragments. When i

  • 0

Fragment

I just started with fragment design for HoneyComb. I created two fragments. When i click the button ‘santhosh'(in left side of pic), one button is created in the another fragment(right side of pic). Next I want to make listener for next button, so that next activity is created in the same fragment(ie. new activity within the right side fragment). My codes below.
main.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" >
<fragment class="com.fragment.example.Titles"
 android:id="@+id/titles" 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>

FragmentExample.java

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


}
 }

Titles.java

public class Titles extends Fragment {
public FragmentTransaction ft;
@Override
public View onCreateView(LayoutInflater inflater,
        ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.main1, null);
    Button button1 = (Button)v.findViewById(R.id.button1);
    button1.setText("santhosh");
    button1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
             DetailsFragment details = (DetailsFragment)
                        getFragmentManager().findFragmentById(R.id.details);
                if (details == null || details.getShownIndex() != 1) {
                    // Make new fragment to show this selection.
                    details = DetailsFragment.newInstance(1);

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

    });
    return v;

}
}

DetailsFragment.java

public class DetailsFragment extends Fragment {
/**
 * Create a new instance of DetailsFragment, initialized to
 * show the text at 'index'.
 */
Titles title = new Titles();
String[] titles = {"Title1", "Title2", "Title3", "Title4"};
public static DetailsFragment newInstance(int index) {
    DetailsFragment f = new DetailsFragment();

    // Supply index input as an argument.
    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) {
    if (container == null) {
        // Currently in a layout without a container, so no
        // reason to create our view.
        return null;
    }
    Button button = new Button(getActivity());
    button.setText("Next");
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

        }

    });
    return button;
}
}

From the DetailsFragment.java i want to display a new Activity with that fragment.

  • 1 1 Answer
  • 1 View
  • 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-26T21:35:07+00:00Added an answer on May 26, 2026 at 9:35 pm

    Next I want to make listener for next button, so that next activity is created in the same fragment(ie. new activity within the right side fragment).

    This is not supported, sorry. Nested activities are deprecated.

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

Sidebar

Related Questions

I just started with fragment design for HoneyComb. I created two fragments. When i
I've just started converting my apps to use fragments. I have a ListView activity
Just started programming in C++. I've created a Point class, a std::list and an
Just started using carrierwave with Rails and things have been going smoothly with one
Just started converting our maps from V2 of the API to v3. Got one
Just started learning shell scripting..just a bit confused between the two. they seem to
Just started getting a bunch of errors on our C# .Net app that seemed
Just started to get my feet wet with C# and .NET, liking it so
Just started with JQuery and I've managed to pass a parameter using POST, firebug
Just started my first MVC 2.0 .net application. And I set up some default

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.