android - Set a ViewFlipper weight programmatically -


i'd change weight of viewflipper programmatically. have tablerow in have 2 columns. first column contains relativelayout element when second column contains viewflipper. viewflipper contains 2 views. somehow in java code, change visible view of viewflipper when click on button. want able, when change viewflipper view (by calling shownext()), change viewflipper weight in order larger in screen.

in other words, first column of row has weight=1 , second (the viewflipper) has weight=0.8. when click on button want change weights programmatically. possible ? how ? below xml code.

i've searched on web, found solution:

myflipper.setlayoutparams(new linearlayout.layoutparams(linearlayout.layoutparams.wrap_content, linearlayout.layoutparams.wrap_content, 0.3f)); 

this doesn't work, crashes, is, think normal viewflipper isn't linearlayout.

here xml code:

    <tablerow     android:layout_width="wrap_content"     android:layout_height="match_parent"     android:background="#00000000" >     <relativelayout         android:id="@+id/rltest"         android:layout_width="0dip"         android:layout_height="match_parent"         android:layout_weight="1"         android:layout_centerinparent="true"         android:paddingleft="6px"         android:paddingright="6px"         android:background="#00000000" >         <textview             android:id="@+id/tvtest"             android:layout_width="match_parent"             android:layout_height="60px"             android:layout_alignparentleft="true"             android:textcolor="#ffffff"             android:textsize="22px"             android:singleline="true"             android:background="#00000000"             android:gravity="center_vertical" />     </relativelayout>     <viewflipper         android:id="@+id/flipper"         android:layout_width="0dip"         android:layout_height="match_parent"         android:layout_weight="0.8"         android:background="#00000000" >         <textview             android:id="@+id/tvname"             android:layout_width="wrap_content"             android:layout_height="60px" />         <linearlayout             android:id="@+id/lltest"             android:layout_width="match_parent"             android:layout_height="60px"             android:layout_centerinparent="true"             android:background="#00000000"             android:gravity="center" />     </viewflipper> </tablerow> 

do have idea ?

thanks

my guess: should using tablerow.layoutparams, not linearlayout.layoutparams. that's guess without seeing actual error; time ask question crash on should include log traceback of error.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -