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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:44:29+00:00 2026-06-15T18:44:29+00:00

I have MainActivity.java as my first Fragment and the another Fragment being Fragment.java having

  • 0

I have MainActivity.java as my first Fragment and the another Fragment being Fragment.java having a TabHost in it. When user clicks on a button in MainActivity, I want to inflate an XML in second fragment’s Tab1.

OnClickListener of the Button in MainActivity is as follows:

btOkButton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {

        LayoutInflater lf = getLayoutInflater();
        Fragment.updateTab1(lf);                
    }               
});

And updateTab1(..) method in Fragment class is:

public static void updateTab1(LayoutInflater lf) {
        lf.inflate(R.layout.xml_to_inflate, (ViewGroup)llTab1, false);
    }

Where:

llTab1 = (LinearLayout)getActivity().findViewById(R.id.tab1);

I am not getting any Exception while doing this, nor Force Close.

In Debug I can see all of this code run without any exception but no required XML being inflated.

  • 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-15T18:44:29+00:00Added an answer on June 15, 2026 at 6:44 pm

    Finally what worked for me:

    As working with fragments I had missed following line in onCreate() to make the inflater object work:

    inflater = getActivity().getLayoutInflater();

    and keeping the rest of code as it is.

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

Sidebar

Related Questions

I have an activity ( MainActivity.java ) in which content view is like this
I have 2 tabs, named : Tab1, Tab2 class MainActivity extends TabActivity. MainActivity.java public
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have an activity, I'll call it mainactivity for now. And I want to
I'm pretty new to Android/java, and have come up against my first head-scratcher. I'm
i have some trouble with my android code here is my MainActivity.java public class
I have an activity named MainActivity. In which I have started another activity (ContentDetails)
i am working on my first project with android and java and have very
First off I'm new to Android and Java.. I have been trying to add

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.