我对这一切都很陌生,我需要一点帮助。
这是我的 axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tableLayout1">
<Button
android:text="Add"
android:id="@+id/button1" />
<TableRow
android:id="@+id/tableRow1"
android:layout_marginTop="10dp">
<TextView
android:text="First Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_column="0"
android:id="@+id/textView12" />
<TextView
android:text="Second Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_column="1"
android:id="@+id/textView13"
android:layout_marginLeft="10dp" />
<TextView
android:text="Colleagues"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_column="2"
android:id="@+id/textView14"
android:layout_marginLeft="10dp" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_column="3"
android:id="@+id/imageView1"
android:layout_marginLeft="10dp" />
<Button
android:text="Delete"
android:id="@+id/button1"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="0.0dp" />
</TableRow>
</TableLayout>
这是我的活动:
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
TableLayout t1 =(TableLayout) FindViewById<TableLayout>(Resource.Id.tableLayout1);
Button add = FindViewById<Button>(Resource.Id.button1); //this is just a test for the add button
add.Click += delegate
{
TableRow tR = new TableRow(this);
TextView tV_txt1 = new TextView(this);
TextView tV_txt2 = new TextView(this);
tV_txt1.Text = "A new row";
tR.SetPadding(0, 0, 0, 0);
tV_txt2.Text = "Another new row ";
tR.AddView(tV_txt1);
tR.AddView(tV_txt2);
t1.AddView(tR);
};
}
}
}
问题是,我找不到从按钮中删除行的方法,删除按钮当然不会影响其他行。我很高兴能得到一些帮助。