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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:47:30+00:00 2026-05-27T13:47:30+00:00

This seems like a simple question that I should be able to find easily

  • 0

This seems like a simple question that I should be able to find easily but I’m having trouble understanding exactly how to create a reusable UI component for Android. Specifically I’m trying to create this snippet that I use EVERYWHERE into a reusable component to make the code smaller.

<RelativeLayout
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="10dp">          
    <TextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:textColor="@color/text_normal"
        android:id="@+id/my_text_id"
        android:text="My field"/>

    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textColor="@color/text_normal"
        android:text="My value"
        android:id="@+id/my_value_id"/>

</RelativeLayout>

These are used like this

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/background_normal"
    android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
          <RelativeLayout
             android:layout_width="fill_parent" 
             android:layout_height="fill_parent"
             android:paddingBottom="0dp"
             android:paddingLeft="10dp"
             android:paddingRight="10dp"
             android:paddingTop="10dp">         
             <TextView
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:textColor="@color/text_normal"
                android:id="@+id/my_text_id"
                android:text="My field"/>

             <TextView 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:textColor="@color/text_normal"
                android:text="My value"
                android:id="@+id/my_value_id"/>

          </RelativeLayout>
    </LinearLayout>
    <LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
          <RelativeLayout
             android:layout_width="fill_parent" 
             android:layout_height="fill_parent"
             android:paddingBottom="0dp"
             android:paddingLeft="10dp"
             android:paddingRight="10dp"
             android:paddingTop="10dp">         
             <TextView
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:textColor="@color/text_normal"
                android:id="@+id/my_text_id2"
                android:text="My field2"/>

             <TextView 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:textColor="@color/text_normal"
                android:text="My value2"
                android:id="@+id/my_value_id2"/>

          </RelativeLayout>
          .... etc ....
    </LinearLayout>
</ScrollView>

I’m hoping to be able to access both text boxes to assign values inside that will be added with the <include /> tag to a layout. Does anyone know how to do this?

I’ve seen http://developer.android.com/resources/articles/layout-tricks-reuse.html but I don’t seem to see how to assign multiple of the same field.

Any help is appreciated.

Update These are used to put a TextView on the left of the screen and another on the right that are lined up together. Not sure how to describe it, but these are used in a ScrollView.

  • 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-05-27T13:47:30+00:00Added an answer on May 27, 2026 at 1:47 pm

    Use <include /> include tag as stated in Android documentation

    To find the component inside your layout:

    findViewById(R.id.includedComponent) 
    

    where R.id.includedComponent is a name of the included component.

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

Sidebar

Related Questions

This seems like a simple question, but I can't find it with the Stack
This seems like a simple question, but it is difficult to search for. I
This seems like it should be really simple, but I'm unable to figure this
This seems like it would be fairly simple, but I've been unable to find
Seems like this should be simple, but powershell is winning another battle with me.
This may seem like a simple question but i am getting an error when
This seems like a simple problem: I have a WF4 activity that guides the
This seems like a very simple and a very common problem. The simplest example
This sure seems like a simple error to fix. However, I somehow can't figure
I'd like to count and group rows by specific values. This seems fairly simple,

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.