티스토리 뷰

SWDesk/App

Dynamic Table Creation Test01

bizmaker 2019. 12. 9. 13:40

<MainActivity.kt>

class MainActivity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        val TL1 = findViewById(R.id.myTableLayout) as TableLayout;
        val TR1 = TableRow(this);
        val B1 = Button(this);
        B1.setText("Dynamic Button");
        TR1.addView(B1);
        TL1.addView(TR1);



    }
}

 

<activity_main.xml>

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TableLayout
            android:id = "@+id/myTableLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        </TableLayout>


        </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

 

 

반응형

'SWDesk > App' 카테고리의 다른 글

Kotlin + RecyclerView 테스트 예제  (2) 2019.12.17
[BPM] BPM User Tool, Ver.1.0  (0) 2019.12.14
Kotlin + Dialog  (0) 2019.12.11
Dynamic Table Creation Test02  (0) 2019.12.11
Dynamic Table Creation Test02 - Wrong Code  (0) 2019.12.09