Note that there are some explanatory texts on larger screens.

plurals
  1. POSwitching 2 rows in a tablelayout in android
    primarykey
    data
    text
    <p>I have a tablelayout in Android like this:</p> <pre><code>1) Row == IMAGEVIEW | TEXTVIEW 2) Row == IMAGEVIEW | SPINNER </code></pre> <p>Now what I need to do is switch the TEXTVIEW/SPINNER. The one from row 2 goes to row 1 and the one from 1 goes to 2.</p> <p>Would be awesome to have a little animation also. I've seen Viewswitcher and Viewflipper but This doesn't seem to be what I am looking for. Anyone got a good idea how to get this to work?</p> <p>My layout (a piece of it) looks like this:</p> <pre><code>&lt;TableRow&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/left_layout_controlls" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:stretchColumns="*" android:id="@+id/top_controlls" android:layout_height="wrap_content"&gt; &lt;TableRow&gt; &lt;ImageView android:id="@+id/fromCountry_img" android:src="@drawable/tc_rt_from" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="fill_parent" /&gt; &lt;TextView android:id="@+id/fromCountry" android:layout_marginTop="2px" android:layout_marginLeft="2px" android:background="@drawable/round_edges_main_controll" android:layout_marginRight="2px" android:layout_height="38px" android:layout_width="160dip"/&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:stretchColumns="*" android:layout_below="@id/top_controlls" android:layout_height="wrap_content"&gt; &lt;TableRow&gt; &lt;ImageView android:src="@drawable/tc_rt_to" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="fill_parent" android:layout_below="@id/fromCountry_img" /&gt; &lt;Spinner android:id="@+id/toCountry" android:layout_height="wrap_content" android:layout_marginTop="2px" android:layout_marginBottom="2px" android:layout_marginRight="2px" android:layout_width="160dip" android:layout_weight="1" android:drawSelectorOnTop="true"/&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <h3>Update:</h3> <p>I've tried to switch the controlls like this, and the animation works, but when the animation ends, the controlls will jump back into their old position.</p> <p>Any idea why?</p> <pre><code>LinearLayout layout1 = ((LinearLayout) DataHolder.activityHolder.findViewById(R.id.top_controll)); LinearLayout layout2 = ((LinearLayout) DataHolder.activityHolder.findViewById(R.id.bottom_controll)); DataHolder.activityHolder.findViewById(R.id.toCountry)); TranslateAnimation a = new TranslateAnimation( Animation.ABSOLUTE,0,Animation.ABSOLUTE,0, Animation.ABSOLUTE,0,Animation.ABSOLUTE, 40); a.setDuration(1200); TranslateAnimation b = new TranslateAnimation( Animation.ABSOLUTE,0,Animation.ABSOLUTE,0, Animation.ABSOLUTE,0,Animation.ABSOLUTE, -40); b.setDuration(1200); layout1.startAnimation(a); layout2.startAnimation(b); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload