Android 运行程序时不显示TableRow和TextView

Android 运行程序时不显示TableRow和TextView,android,android-layout,tablerow,Android,Android Layout,Tablerow,我创建了这个TableLayout,然后创建了TableRow和其中的3个TextView。 当我运行应用程序时,它不会显示任何帮助?! 这是我的布局: 基本上,我希望在从sqlite数据库检索数据时以编程方式添加更多的TableRows <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/ap

我创建了这个
TableLayout
,然后创建了
TableRow
和其中的3个
TextView
。 当我运行应用程序时,它不会显示任何帮助?! 这是我的布局:

基本上,我希望在从sqlite数据库检索数据时以编程方式添加更多的TableRows

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/TableLayoutv">

    <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="wrap_content"
        android:gravity="center">

        <TextView
            android:text="Code"
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:textSize="20sp"
            android:textStyle="bold">
        </TextView>
        <TextView
            android:text="Village"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="20sp"
            android:textStyle="bold">
        </TextView>
        <TextView
            android:text="Pays"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="20sp"
            android:textStyle="bold">
        </TextView>

    </TableRow>
</TableLayout>

请在文本视图中添加正确的颜色。我假设背景和文本视图都是白色的?我添加了颜色。但是当我运行程序时,文本视图中的文本仍然不显示。还有其他建议吗?它在android studio布局中可见吗?是的,它在布局中可见。但在我的设备中不可见。我将添加一个编辑。适合我。想在课堂上展示主要活动吗?
    import android.database.Cursor
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Gravity
import android.widget.TableLayout
import android.widget.TableRow
import android.widget.TextView
import java.sql.SQLException

class ShowVillages : AppCompatActivity() {
    private val tablelayoutv: TableLayout = findViewById(R.id.TableLayoutv)
    private lateinit var db: DatabaseHelper
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_show_villages)

        db = DatabaseHelper(this)
       buildTable()

    }

   private fun buildTable() {

       try {
           val crs: Cursor = db.getDataVillage2()
           if (crs.count != 0) {
               if (crs.moveToFirst()) {
                   do {
                       val rows = crs.count
                       val cols = crs.columnCount
                       // outer for loop
                       for (i in 1..rows) {
                           val row = TableRow(this)
                           row.layoutParams = TableRow.LayoutParams(
                               TableLayout.LayoutParams.MATCH_PARENT,
                               TableLayout.LayoutParams.WRAP_CONTENT
                           )
                           for (j in 1..cols) {
                               //creation text view
                               val tv1 = TextView(this)
                               tv1.layoutParams = TableRow.LayoutParams(
                                   TableLayout.LayoutParams.MATCH_PARENT,
                                   TableLayout.LayoutParams.WRAP_CONTENT
                               )
                               tv1.gravity = Gravity.START
                               tv1.textSize = 10F
                               tv1.setPadding(0, 5, 0, 5)
                               tv1.text = crs.getString(j)
                               row.addView(tv1)
                           }
                           tablelayoutv.addView(row)
                       }
                   } while (crs.moveToNext())
               }
           }
       } catch (mSQLException: SQLException) {
           throw mSQLException
       }

   }

}