티스토리 뷰
strings.xml
<resources>
<string name="app_name">혀가 길지 않은 개발자 KotlinProject</string>
<string name="name">James Kim</string>
<string name="nickname">혀가 길지 않은 개발자</string>
</resources>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/name"
android:textSize="30dp"
android:textStyle="bold|italic"/>
<Button
android:id="@+id/btnChange"
android:layout_width="200dp"
android:layout_height="70dp"
android:textAllCaps="false"
android:text="change"
android:textSize="20dp"
android:layout_marginTop="10dp" />
</LinearLayout>
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
btnChange.setOnClickListener {
if (tvName.text == getString(R.string.nickname)) {
tvName.text = getString(R.string.name)
} else {
tvName.text = getString(R.string.nickname)
}
}
}
}
'Android > XML' 카테고리의 다른 글
<View> (0) | 2020.08.04 |
---|---|
<TabLayout> (0) | 2020.08.04 |
<include>, <ImageView>, <ImageButton> (0) | 2020.08.04 |
styles-v21 패키지 만들기 (0) | 2020.08.04 |
StatusBarColor (0) | 2020.08.03 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Design Pattern
- MVVM
- handler
- Vue.js #Vue.js + javascript
- 안드로이드
- XML
- 혀가 길지 않은 개발자
- Intent
- activity
- ArrayList
- 안드로이드 #코틀린 #Android #Kotlin
- recyclerview
- Livedata
- James Kim
- ViewModel
- TabLayout
- Architecture Pattern
- DataBinding
- 코틀린
- JSONObject
- ViewPager2
- java
- JSONArray
- Kotlin
- fragment
- CoordinatorLayout
- Android
- 자바
- View
- coroutine
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함