I have this xml file for my activity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Spinner
android:id="@+id/spinner_strassenfuehrer_fb_screen"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TableLayout
android:id="@+id/tablelayout_strassenfuehrer_fb_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" >
<TableRow
android:scrollbars="vertical"
android:background="#A6A6A6"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Störcode" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Bezeichnung" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Letztes Auftreten" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Anlagen ID" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Projekt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Benötigte Ersatzteile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Benötigtes Werkzeug" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:layout_weight="1"
android:text="Handlungsleitfaden" />
</TableRow>
</TableLayout>
And my code is:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fehlerdatenbank_strassenfuehrer_screen);
//read database and put values dynamically into table
tableLayout = (TableLayout) findViewById(R.id.tablelayout_strassenfuehrer_fb_screen);
for (int i = 0; i < 100; i++) {
TableRow row = new TableRow(this);
row.canScrollVertically(1);
//column 1
TextView tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 2
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 3
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 4
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 5
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 6
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 7
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
//column 8
tv = new TextView(this);
tv.setText("TEST");
row.addView(tv);
tableLayout.addView(row, i + 1);
}
}
I am new in android and I would like to make the rows scrollable, but not the "first" row, from my xml-layout.
Also I would like to fit the elements, which I put dynamically into my TableLayout
because the elements not fit on the column.
I am new in android and would be happy, if someone can help me out :)
Thank you