티스토리 뷰

SWDesk/App

Dynamic Table Creation Test02

bizmaker 2019. 12. 11. 18:06
class MainActivity : AppCompatActivity() {

    lateinit var TR1:TableRow
    lateinit var TR2:TableRow
    lateinit var B1:Button
    lateinit var B2:Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        val TL1 = findViewById(R.id.myTableLayout) as TableLayout;

        TR1 = TableRow(this)
        TR2 = TableRow(this)
        B1 = Button(this)
        B2 = Button(this)

        B1.setText("Dynamic Button1")
        TR1.addView(B1)
        B2.setText("Dynamic Button2")
        //TR1.addView(B2)
        TR2.addView(B2)
        TL1.addView(TR1)
        TL1.addView(TR2)
        h_ChangeName();
    }

    fun h_ChangeName(){
        B1.setText("Dynamic Button1-1");
    }
}

반응형

'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 - Wrong Code  (0) 2019.12.09
Dynamic Table Creation Test01  (0) 2019.12.09