Я пытаюсь динамически изменить столбец параметров 2-й строки.Когда я нажимаю кнопку, ничего не происходит, не перемещается из положения, остается в положении 0. Есть мысли по этому поводу?
Вот мой XML-файл:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background = "#fff"
android:orientation="vertical">
<Button android:text="Button" android:id="@+id/button1"></Button>
<TableLayout android:id="@+id/tableLayout2" android:layout_height="fill_parent"
Android: layout_width="250dp"
Android: stretchColumns="*"
Android: layout_gravity="center"
Android: gravity="center_vertical">
<TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/echart"/>
<ImageView android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:src="@drawable/echart"/>
<ImageView android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/echart"/>
</TableRow>
<TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:id="@+id/mCursor"
android:src="@drawable/cursor"/>
</TableRow>
И мой код:
public class TestTableRowActivity extends Activity implements OnClickListener {
private Button btn;
static ImageView mCursor;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button)this.findViewById(R.id.button1);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
mCursor= (ImageView)findViewById(R.id.arrow1);
mCursor.setLayoutParams(new TableRow.LayoutParams(2));
}
}