I have created a Table Layout named table and I am trying to add the table reference id (R.id.table)
TableLayout table = (TableLayout) findViewById(R.id.table);
using the following and populate by table with text Views
The application gets crashed when i am executing this.. I debugged and inspected the Code
carefully I saw the R.id.table value is returning null but there is no compiler error
Here is my table.xml, its a Layout file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrol"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/dummy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<TableLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow
android:id="@+id/tablerow"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>
</LinearLayout>
Is my approach is right or wrong .. Whether i have to refer the Row id of the Table table ?? Is there any way to create Dynamic Table layout ??
I was googling all around for this but i dont fine any suitable examples for this.. can anybody help me in this??
Thanks in advance
This may be useful for you
in first.xml you create
in second.xml
In your class