The function of the project is to implement a table displayed in an activity
The following code is the code in Mainactivity.java
Packagecom.example.tablelayout;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.Menu;ImportAndroid.view.MenuItem; Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); }}
The following code is the code in Activity_main.xml
<tablelayout xmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:id= "@+id/tablelayout1"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:stretchcolumns= "1"Tools:context= "${relativepackage}.${activityclass}" > <!--because fill_parent cannot be filled, stretchcolumns specifies Lela and <table Row> <TextView Android:text= "@string/hello_world"android:padding= "3dip"Android:background= "#aa0000"/> <TextView Android:text= "@string/hello_world"android:padding= "3dip"Android:background= "#00aa00"android:gravity= "Center_horizontal"/> <TextView Android:text= "@string/hello_world"android:padding= "3dip"Android:background= "#0000aa"android:gravity= "Right"/> </TableRow> <TableRow> <TextView Android:text= "@string/hello_world"android:padding= "3dip"/> <TextView Android:text= "@string/hello_world"android:padding= "3dip"android:gravity= "Right"/> </TableRow></TableLayout>
Android Learning Note--tableview