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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:35:55+00:00 2026-05-27T08:35:55+00:00

On my TableLayout, one TableRow has a TextView, and another has a Spinner. When

  • 0

On my TableLayout, one TableRow has a TextView, and another has a Spinner. When the user checks a checkbox, I want to swap the positions of these 2 views. The Spinner needs to move to the position of the TextView, and the TextView needs to move to the position of Spinner.

Animation doesn’t matter. The preference would be that it happens instantly, but I could make it a super-fast animation if necessary.

I have been surprised at how much trouble I’ve had trying to locate a solution to this problem :/ On a similar note, the Android dev ref could really use some simple examples a la the MSDN library.

Thanks!

  • 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-27T08:35:56+00:00Added an answer on May 27, 2026 at 8:35 am

    Here is the code I ended up using to swap the views:

    import android.widget.TableRow;
    
    TableRow trI = (TableRow) findViewById(R.id.tr_input_row);
    TableRow trO = (TableRow) findViewById(R.id.tr_output_row);
    View v1 = (View) findViewById(R.id.View1);
    View v2 = (View) findViewById(R.id.View2);
    
    if (isInput()) {
        trO.removeView(v1);
        trI.removeView(v2); 
        trO.addView(v2);
        trI.addView(v1);
    } else {
        trO.removeView(v2);
        trI.removeView(v1); 
        trO.addView(v1);
        trI.addView(v2);
    }
    

    In my case, the views were in two different rows of a TableLayout. I’m using TableRow because it is the type of the parent of the views I want to swap. I assume this could be updated to be whatever type of parent the target views have.

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

Sidebar

Related Questions

I have two EditText controls in one TableLayout>TableRow. I have another TableLayout>TableRow that has
Context: I have a TableLayout (created using XML), which has one TableRow, which has
I'm using a TableLayout in Android. Right now I have one TableRow with two
i have created following layout. <TableLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=horizontal > <TableRow> <TextView android:layout_width=fill_parent android:layout_height=wrap_content
My Android application currently has TableLayout with several TableRow s containing an ImageView then
As above, How do i put 2 views inside one cell in a tablerow
I'm trying to create an android screen that has a TableLayout anchored to the
I have list of products which have EditText in TableLayout . I want Keyboard
Hey I want to make a view appear below the last that has been
I have an xml file right now which has a TableLayout within a LinearLayout.

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.