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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:34:01+00:00 2026-06-08T06:34:01+00:00

I have the following XML layout driving my UI: <TableLayout android:id=@+id/tableLayout1 android:layout_width=fill_parent android:layout_height=wrap_content android:stretchColumns=1

  • 0

I have the following XML layout driving my UI:

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:layout_margin="10dp" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Username:" />

        <EditText
            android:id="@+id/txtUsername"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPersonName" >

        </EditText>

    </TableRow>

       <!-- more rows are here -->

</TableLayout>

I want to reuse this layout for another section of my app, but change something just slightly in one spot. I would like the EditText txtUsername to be changed to a TextView, in the same location and everything. So basically I am swapping out the EditText for a TextView in code.

How do I do this?

  • 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-08T06:34:03+00:00Added an answer on June 8, 2026 at 6:34 am

    If that is the only change you need I would do it by adding the TextView into your layout (defaulted to View.GONE) and using View.setVisibility(View.VISIBLE) and View.setVisibility(View.GONE) where appropriate to swap them.

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Username:" />
    
        <EditText
            android:id="@+id/txtUsername"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPersonName" >
    
        </EditText>
        <TextView
            android:id="@+id/txtUsernameTV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPersonName" 
            android:visibility="gone">
    
        </TextView>
    </TableRow>
    

    Then in your java you can leave the activity you already have the same, in the new activity(where you want the TextView instead) do something like this:

    editTextReference.setVisibility(View.GONE);
    textViewReference.setVisibility(View.VISIBLE);
    

    note that the two Views will need different values for their id.

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

Sidebar

Related Questions

This is maddening. I have the following XML layout: <FrameLayout android:layout_width=fill_parent android:layout_height=wrap_content android:background=@drawable/shadow android:focusable=true
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have the following XML: <LinearLayout android:id=@+id/linearLayout1 android:layout_width=fill_parent android:layout_height=wrap_content > <TextView android:id=@+id/tv1 android:layout_width=wrap_content android:layout_height=wrap_content
hi i have the following xml layout <Button android:id=@+id/signupButton android:layout_gravity=left android:layout_width=100sp android:layout_height=wrap_content android:layout_marginLeft =
I have the following XML layout: <LinearLayout android:id=@+id/map_locations_list android:layout_width=300dp android:layout_height=fill_parent android:layout_marginLeft=8dp android:layout_marginTop=8dp android:layout_marginBottom=8dp android:background=@color/black_shadow
In my XML, I have the following <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=fill_parent > </ListView> How
I have following main.xml of layout <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <TextView android:id=@+id/textview01
I have the following XML: <?xml version=1.0 encoding=utf-8?> <RelativeLayout android:id=@+id/rl android:background=@color/red android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android=http://schemas.android.com/apk/res/android>
I have a custom View extending SurfaceView. The XML layout is <com.myPackage.MyCustomView android:id=@+id/mycview android:layout_width=fill_parent
I have the following ToggleButton in xml: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=46dp android:gravity=center > <ToggleButton

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.