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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:50:22+00:00 2026-06-15T11:50:22+00:00

Considering this LinearLayout containing.. One nested Linear Layout with two child views one imageView

  • 0

Considering this LinearLayout containing..

  • One nested Linear Layout with two child views

    • one imageView

    • one Textview

  • One textView

  • One Button

Why can I successfully show text content on the outer TextView using findViewById and setText while the inner Textview (inside nested linear view) shows blank?

Here is the code for onCreate:

LayoutInflater inflater = LayoutInflater.from(Item.this);
LinearLayout itemLayout = (LinearLayout)inflater.inflate(R.layout.activity_item, null);            
Button proformaButton = (Button)itemLayout.getChildAt(2);

roformaButton.setOnClickListener(this);


setContentView(itemLayout);

TextView titleTitla = (TextView)findViewById(R.id.item_title);
TextView itemBody = (TextView)findViewById(R.id.item_body); 

titleTitla.setText("Tomatoes");
itemBody.setText("Potatoes");

While debugging I can see that the view is found by Id and I can also see that setText does it work (mText field of TextView), but the activity does not show anything for item_title.

I am asking how to fix this but if it’s not a trivial thing a hint of explanation would be very appreciated.

If it helps, here’s the xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:orientation="horizontal"
        android:layout_weight="1">

        <ImageView
            android:id="@+id/item_picture"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:contentDescription="@string/image_item">
        </ImageView>

        <TextView 
            android:id="@+id/item_title"
            android:layout_width="0dip"
            android:layout_height="fill_parent">
        </TextView>

    </LinearLayout>

    <TextView 
        android:id="@+id/item_body"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="2">
    </TextView>

    <Button
         android:id="@+id/btnOrderItem"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/order_button"
    />

</LinearLayout>
  • 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-15T11:50:24+00:00Added an answer on June 15, 2026 at 11:50 am
        <TextView 
            android:id="@+id/item_body"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="2">
        </TextView>
    

    It’s the layout_height="0dp". The reason it works on the other LinearLayout is because you have a weight attribute. Change the 0dp to wrap_content.

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

Sidebar

Related Questions

Considering this: [Flags] public enum MyEnum { One = 1, Two = 2, Four
AFAIK, all types are derived from System.Object class. Considering this, how can I calculate
Considering this code, can I be absolutely sure that the finally block always executes,
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
Considering this code with 3 differents function call semantics: void f(void){ puts(OK); } int
considering this example: public static void main(final String[] args) { final List<String> myList =
Considering this xml document: DECLARE @X XML (DOCUMENT search.SearchParameters) = '<parameters xmlns=http://www.educations.com/Search/Parameters.xsd xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> <parameter
Considering this question of SO, where whole C# in-memory compiler is being called. When
Considering this article Developing a MVC component for Joomla , following is the code
I'm considering using this jquery utility as a possible solution, but I want 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.