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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:10:24+00:00 2026-06-08T15:10:24+00:00

I’m trying to insert a LinearLayout inside another LinearLayout . I don’t know if

  • 0

I’m trying to insert a LinearLayout inside another LinearLayout. I don’t know if what I am doing is right or not. I need to try it this way, without using inflation.

      LinearLayout address2;
      address2 = new LinearLayout(this);
      address2 = (LinearLayout)findViewById(R.id.sfsp2_layout);

      LinearLayout teste3 = (LinearLayout)findViewById(R.id.se_contentAdressPostal);

      LinearLayout teste4 = (LinearLayout)teste3.findViewWithTag("teste");
      teste4.addView(address2);

LinearLayout teste3

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/se_contentAdressPostal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:background="@drawable/background_tile_address_postal"
    android:orientation="vertical" >

    <include
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        layout="@layout/socio_form_structured_postal" />

LinearLayout teste4

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sfsp_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/background_tile"
    android:orientation="vertical"
    android:tag="teste" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/sfsp_layout_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="49dp"
        android:layout_gravity="right"
        android:background="@drawable/background_tile"
        android:orientation="horizontal"
        android:tag="teste" >
        <Button
            android:id="@+id/sfsp_btStructuredPostal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_marginBottom="2dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="2dp"
            android:hint="@string/sfsp_btStructuredPostal" /> .......

LinearLayour address2 ( The layout that i need to insert in layout4)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sfsp2_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/background_tile"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/sfsp2_etStructuredPostalApartado"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2dp"
        android:layout_marginLeft="65dp"
        android:layout_marginRight="55dp"
        android:layout_marginTop="2dp"
        android:layout_weight="0.14"
        android:ems="10"
        android:hint="@string/sfsp2_etStructuredPostalApartado"
        android:inputType="textMultiLine"
        android:scrollHorizontally="false" >

The LinearLayout “teste4” is inside “teste3”. I need to insert LinearLayout “address2” inside “teste4”. Can you tell me what I’m doing wrong?.

  • 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-08T15:10:26+00:00Added an answer on June 8, 2026 at 3:10 pm

    I think there is some misunderstanding here about how the findViewById works. I’ll try to explain it below. Hope this helps, let me know if it doesn’t.

    There are two possible findViewById() that can be used.

    1. Activity.findViewById(): this can be used to find a view in the current activity’s main content view — that is, the view that was set using setContentView(). It cannot be used for any other purpose. For example, it cannot find a view from any other layout file — the function simply would have no way of knowing how to find it. As far as I can tell, this is the function you’re trying to use. If the last XML file you have is not the main layout, then the line address2 = (LinearLayout)findViewById(R.id.sfsp2_layout) will fail.

    2. View.findViewById(): this function can be used to find a view that is contained in some other view. E.g. if you have view1 that contains view2, and view2 has ID some_id, then you can find view2 by calling view1.findViewById(R.id.some_id). In order for this to work, view1 has to be fully initialized. E.g. if view1‘s description is in XML, it has to be fully inflated first.

    In essence, if you want to work with a view that is described in a separate XML file, you have to inflate it first. I don’t think there is a way around it.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I know there's a lot of other questions out there that deal with this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.