I'm trying to get data from sqlite database into tablelayout want each each row of the database be in the row of the table ... I'm kind of new to the Android world so I just did get each column of the database into table column .. but I couldn't make each row in the db into the row of the table. Hope anyone can help. So this is the xml file:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="@+id/tabla_cuerpo"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#000000">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000"
android:textStyle="bold"
android:gravity="center_horizontal"
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/textview"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="جدول المواد"/>
</TableRow>
<TableRow >
<TextView
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/tv1"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/textv"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/tv2"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/tv3"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/tv4"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:background="#FFFFFF"
android:layout_margin="1dip"
android:id="@+id/tv5"
android:layout_weight="0.3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</TableRow>
and this is the java file that tries to get the data
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.subjectschd);
TextView tv1 =(TextView) findViewById(R.id.tv1);
TextView tv2 =(TextView) findViewById(R.id.tv2);
TextView tv3 =(TextView) findViewById(R.id.tv3);
TextView tv4 =(TextView) findViewById(R.id.tv4);
TextView tv5 =(TextView) findViewById(R.id.tv5);
Getdata info = new Getdata (this);
info.openDataBase();
String data=info.gettermsched();
String data2=info.getermsched2();
String data3=info.getermsched3();
String data4=info.getermsched4();
String data5=info.getermsched5();
tv1.setText(data);
tv2.setText(data2);
tv3.setText(data3);
tv4.setText(data4);
tv5.setText(data5);
info.close();
This is how I got the columns .. I don't have any idea of how I can get the rows too. I'll appreciate any help really.