Android Application

Kotlin 액티비티(Activity) : UI 테스트

작성자 임베디드코리아 작성일23-10-22 01:42 조회1,508회 댓글0건

첨부파일

Kotlin 액티비티(Activity) : UI 테스트
------------------------------------------------------------------------------------
    MainActivity.kt
------------------------------------------------------------------------------------
class MainActivity : AppCompatActivity() {
    private lateinit var container: LinearLayout
    private lateinit var btn1: Button
    private lateinit var btn2: Button

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

        container =  LinearLayout(this)
        container.setOrientation(LinearLayout.VERTICAL)

        btn1 = Button(this)
        btn1.setText("첫번째 버튼")
        btn2 =  Button(this)
        btn2.setText("두번째 버튼")

        container.addView(btn1)
        container.addView(btn2)

        setContentView(container)
    }
}