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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:00:49+00:00 2026-06-18T10:00:49+00:00

Hope you’re fine & Congrats for your Work ! Scenario : I have 3

  • 0

Hope you’re fine & Congrats for your Work !
Scenario :
I have 3 fragments files, Pagegauchefragment, PageMilieufragment & PageDroiteFragment managed by 2 files FragmentsSliderActivity and MyPagerAdapter.
The first one and the second one are datas fields with EditText, filled by the user. Last one is a ListView where the datas user files are saved. From the listview (last fragment) the user clicks the file with 3 possibilities : 1. Import the file / 2. delete the file / 3. Cancel (I use the action bar process to save the datas). Now the issue : I can’t pass my datas to refresh (with setText) to the other fragments.
Log : Tag : IIputConnectionWrapper / Text : getSelectedText on inactive InputConnection, setComposingText on inactive InputConnection.

  View W =inflater.inflate(R.layout.page_droite_layout,container, false);
     this.mListView = (ListView) W.findViewById(R.id.ListView01);
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_list_item_1, tabRevues);
     this.mListView.setAdapter(adapter);

     this.mListView.setOnItemClickListener(new OnItemClickListener() {           

        @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
             View WW =inflater.inflate(R.layout.page_gauche_layout,container, false);
             file_name = (EditText) WW.findViewById(R.id.label_LiquidBase);


             //int item = position;
             item_name = ((TextView)view).getText().toString();
             AlertDialog.Builder ad = new AlertDialog.Builder(getActivity());               

             ad.setTitle("Selection Recettes : " + item_name);
             ad.setMessage("Que souhaitez-vous faire ?");

             ad.setPositiveButton("Importer", 
                     new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int id) {                           
                            try {

Here I pass a text to setText (for example) :

file_name.setText("blahblah");

I think I’m in a Void method but I can’t find out how to pass the variables… ANY help whatsoever will be greatly appreciated!
Christopher

  • 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-18T10:00:50+00:00Added an answer on June 18, 2026 at 10:00 am

    Passing data directly between Fragments is never recommended. Instead, pass your data from Fragment X up to your FragmentsSliderActivity which will pass this data on to your Fragment Y. You do that by way of an interface defined in your fragment class and instantiate a callback that is defined in onAttach().

    More information on how to do this here
    Communication With other Fragments

    Quick example, consider Fragment A and Fragment B. Fragment A is a list fragment and whenever an item is selected it will change what is displayed in Fragment B. Simple enough, right?

    At first, define Fragment A as such.

     public class FragmentA extends ListFragment{
    
       //onCreateView blah blah blah
    
    }
    

    And here’s Fragment B

    public class FragmentB extends Fragment{
    
     //onCreateView blah blah blah
    
    }
    

    And here’s my FragmentActivity that will govern them both

    public class MainActivity extends FragmentActivity{
    
    //onCreate 
    //set up your fragments
    
    }
    

    Presumably you have something like this already, now here’s how you would change FragmentA(the list fragment that we need to get some data from).

        public class FragmentA extends ListFragment implements onListItemSelectedListener, onItemClickListener{
    
    OnListItemSelectedListener mListener;
    
       //onCreateView blah blah blah
    
    
    
     // Container Activity must implement this interface
        public interface OnListItemSelectedListener {
        public void onListItemSelected(int position);
    }
    
    
    }
    
    
      @Override
      public void onAttach(Activity activity) {
        super.onAttach(activity);
    
        // This makes sure that the container activity has implemented
        // the callback interface. If not, it throws an exception
        try {
            mListener = (OnListItemSelectedListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement OnListItemSelectedListener");
        }
    }
    
    
      @Override 
     public void onItemClick(AdapterView<?> parent, View view, int position, long id){
    
    
     //Here's where you would get the position of the item selected in the list, and  pass    that position(and whatever other data you need to) up to the activity 
    //by way of the interface you defined in onAttach
    
      mListener.onListItemSelected(position);
    
    
    }
    

    The most important consideration here is that your parent Activity implements this interface, or else you will get an exception. If implemented successfully, everytime an item in your list fragment is selected, your Activity will be notified of it’s position. Obviously you could alter your interface with any number or type of parameters, in this example we’re just passing in our integer position. Hope this clarifies a bit man, good luck.

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

Sidebar

Related Questions

Hope you all are fine and rocking your code editors. My question is how
Hope you can help me with this: So, I have Nivo slider working fine
hope you all are fine and also in one of your best of moods!!
Hope you all will be fine. The scenerio is that i have a page
Hope the AWK gurus can provide a solution to my problem . I have
Hope someone could help me with this: I would like to have a column
Hope someone will give me a hand with this problem I have. So here
Hope I'm asking this correctly: I have a project Projects.Client I have my class
hope if someone can help me. i have a simple webpage nad i want
Hope someone can assist with this, it's driving me crazy. I have a class

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.