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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:05:56+00:00 2026-06-15T14:05:56+00:00

Hai i’m new to this fragments development in android. My Question is navigation between

  • 0

Hai i’m new to this fragments development in android. My Question is navigation between the fragments. I have a button in fragment 1 and a text view in fragment2 and i have activity activity1 where i declared both these fragments in xml. My question is when i press the button in fragment1, it has to carry some text and display in the textview of fragment2 before that it has to check whether the fragment2 is in the same layout or not?

Code will be very helpful to me. Thanks in advance……….

  • 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-15T14:05:57+00:00Added an answer on June 15, 2026 at 2:05 pm

    At first declare your inflater into onCreateView (in 2ndFragmentClass) like below:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_content, container, false);
    
        return view;
    }
    

    Please consider fragment_content must at lease have a TextView inside itself (So that we set its value inside the fragment). Then we have to change the value of this text from the 1st fragment. So we add this constructor inside our 2nd Fragment (the fragment containing TextView) like below:

    public void setText(String name) {
        TextView txt= (TextView ) getView().findViewById(R.id.textView1);
        txt.setNewText(name);
      }
    

    Simply, it would be like below:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_content, container, false);
    
        return view;
    }
    public void setText(String name) {
        TextView txt= (TextView ) getView().findViewById(R.id.textView1);
        txt.setNewText(name);
      }
    

    Then we must define which text must be set into 2nd Fragment from 1stFragmentClass. Then we set the text of the 2nd fragment by pressing button in 1st fragment like below:

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        String url = "Hello, This is the text from 1st Fragment:)";
             //Here we try to declare 2nd fragment.
        2ndFragmentClass fragment = (2ndFragmentClass) getFragmentManager()
                .findFragmentById(R.id.detailFragment);
            fragment.setNewText(url);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hai i am new bie to Android. i need to check the network connection
hai I have a Spanish site in php. In this a mail body contain
Hai presently i have grid like this. <Grid Name=tGrid1 Grid.Row=0 Background=Black > </Grid> <Grid
hai i am very new to jquery and jqgrid.. i have implemented a grid...but
Hai I am new to the Android. I am using Android4 sdk. I can't
Hai every one i have a 2 textbox and 1 button in page1.html .when
Hai i have a button and dropdown.When i change the dropdown i hide the
Hai! I am new to android. I want to store the images into the
Hai all I am new in android programming..... For my application I am using
Hai I have an application which is designed in netbeans6.0.1 where i need to

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.