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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:48:34+00:00 2026-05-29T19:48:34+00:00

I am planning on having 3 fragmentlists contained within one activity. The goal is

  • 0

I am planning on having 3 fragmentlists contained within one activity. The goal is you select the talk option from the first list, then it transitions to the run list based on what you clicked in talk list, and then in the run list, based on what you click it will transition to the final eat list. Should this be happening in the fragments themselves(like i have it) or calling the activity to handle passing data back and forth to the fragments?

public class OptionsActivity extends Activity {

    protected TalkFragment talk;
    protected RunFragment run;
    protected EatFragment eat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        talk = new TalkFragment();
        run = new RunFragment();
        eat = new EatFragment();
    } 
}


public class TalkFragment extends ListFragment {
    private Cursor mCursor;
    int mCurCheckPosition = 0;

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

    }
    @Override
    public void onListItemClick(ListView l, View v, int pos, long id) {
        mCurCheckPosition = pos;
        // We can display everything in-place with fragments.
        // Have the list highlight this item and show the data.
        getListView().setItemChecked(pos, true);

        // Check what fragment is shown, replace if needed.
        RunFragment run_frag = (RunFragment) getFragmentManager().findFragmentById(R.id.fragment_run);
        if (run_frag == null || run_frag.getShownIndex() != pos) {
            run_frag = RunFragment.newInstance(pos);
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.replace(R.id.details, details);
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            ft.commit();
        }

    } 
}

This is obviously just snippits, but you get the idea. If I do it this way, I am not really sure how to pass certain parameters to fragment properly. Ideally, the RunFragment would know what to display based on the id of the item clicked in the TalkFragment. Should these be going through the Activity instead?

  • 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-29T19:48:35+00:00Added an answer on May 29, 2026 at 7:48 pm

    The way I typically do it is have the Activity be the traffic cop for handling the fragments. Your onListItemClick implementation could just tell the Activity what it wants to do:

    public class OptionsActivity extends Activity {
    
        protected TalkFragment talk;
        protected RunFragment run;
        protected EatFragment eat;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            talk = new TalkFragment();
            run = new RunFragment();
            eat = new EatFragment();
        }
    
        public void showRunFragment() {
            showFragment(R.id.fragment_run);
        }
    
        public void showEatFragment() {
            showFragment(R.id.fragment_eat);
        }
    
        public void showFragment(int fragmentId) {
            // Check what fragment is shown, replace if needed.
    
            ...
        }
    }
    
    
    public class TalkFragment extends ListFragment {
        private Cursor mCursor;
        int mCurCheckPosition = 0;
    
        @Override
        public void onActivityCreated(Bundle savedState) {
            super.onActivityCreated(savedState);
    
        }
    
        @Override
        public void onListItemClick(ListView l, View v, int pos, long id) {
            mCurCheckPosition = pos;
            // We can display everything in-place with fragments.
            // Have the list highlight this item and show the data.
            getListView().setItemChecked(pos, true);
    
            getActivity().showRunFragment()
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to design an edifact parser, I was planning on having one
I'm planning on switching from having my blog on wordpress.com to having it on
We are planning on having a policy to prevent commits to trunk. All commits
I'm planning to make a simple Photo Resizer since I usually find myself having
I'm planning to implement my own set of constraints, and am having some difficulty
Does anybody know if Microsoft is planning on having IE9 pass with 100/100 on
I am planning a dynamic PHP photo gallery and having difficulty deciding on the
We are planning to upgrade our Tomcat from 4.1.31. Our's is an Axis 1.4
Basically I need the image of fast changing numbers. I am planning on having
So the problem I am having has not actually happened yet. I am planning

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.