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

  • Home
  • SEARCH
  • 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 8961331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:51:58+00:00 2026-06-15T15:51:58+00:00

I have activity_main which is default layout in my activity, there i have framelayout

  • 0

I have activity_main which is default layout in my activity, there i have framelayout which display fragment whit different layout, is it possible to connect the different layout textview to setText() from my activity? How to connect from activity to this fragment xml layout?

activity_main
   frameLayout
      fragment 1 xml
      fragment 2 xml
   /frameLayout

Activit.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    dirShow("a");
}


void dirShow(String s) {
    setContentView(R.layout.fragment1);
    textPath = (TextView) findViewById(R.id.path_text);
    textPath.setText(s);
}
  • 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-15T15:52:00+00:00Added an answer on June 15, 2026 at 3:52 pm

    You shouldn’t be calling setContentView more than once in an activity. The content view is the entire activity layout. If you want to change the layout the proper way to do it is to change the fragment or activity, and have the new activity or fragment show the new layout.

    If you’re not trying to change layouts, then just put the TextView you need in the first layout that you set. Posting your layout files and telling us what you’re trying to do may allow us to help you achieve what you want.

    EDIT:
    If I understand your updated question correctly, you’re using Fragments. If that’s the case, call the dirShow() function in the Fragments onCreateView() function instead of the activity’s onCreate() function.

    If you’re just incorrectly using the term fragment in your question, I suggest you switch to using them.

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

Sidebar

Related Questions

I have a MainActivity the default start up Activity which creates a TCP worker
i have main activity in which i have Four menus. and i have one
I am making an app in which i have a main activity that the
I have a Tabhost which is my main activity. When a tab is clicked
If I have a login screen and then the activity which displays the main
Say if I have a locationManager(LM) object in activity A, which is my main
I have a notification which should give me some parameters when opening an activity
I am using fragments to show images/pages.I have one Activity(Main) which contains all the
In my Android application I have a main activity MyActivity which overrides onConfigurationChanged() method.
I have an Activity which has an 'OK' button. And I have an 'Edit'

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.