Android Application
작성자 임베디드코리아
작성일23-08-22 00:04
조회2,299회
댓글0건
-----------------------------------------------------------------------
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">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textStyle="bold"/>
</androidx.constraintlayout.widget.ConstraintLayout>
--------------------------------------------------------------------------------
MainActivity.kt
-------------------------------------------------------------------------------------
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var textView : TextView = findViewById(R.id.textView);
//문자
var mString : String = "EmbeddedKorea";
val isChar: Char='K';
//정수
var mInt : Int = -300;
var mLong : Long = -3;
// unsigned 정수
var mUInt : UInt = 123u;
var mULong : ULong = 3u;
//실수
var mDouble : Double = 2.3;
var mFloat : Float = 4.0f;
//논리형
val isReal: Boolean;
isReal=false;
//Byte
val isByte: Byte;
isByte=-123;
//UByte
val isUByte: UByte;
isUByte=123u;
//Show
val isShort: Short;
isShort=-456;
//Show
val isUShort: UShort;
isUShort=456u;
//Any
val isAnyInt1: Any?;
val isAnyInt2: Any;
isAnyInt1=10;
isAnyInt2=isAnyInt1;
val isAnyString: Any;
isAnyString="kilsung";
//텍스트뷰에 담기
textView.append("String: " + mString + "\n");
textView.append("Char: " + isChar+ "\n");
textView.append("Int: " + mInt.toString() + "\n");
textView.append("UInt: " + mUInt.toString() + "\n");
textView.append("Long: " + mLong.toString() + "\n");
textView.append("ULong: " + mULong.toString() + "\n");
textView.append("Double: " + mDouble.toString() + "\n");
textView.append("Float: " + mFloat.toString() + "\n");
textView.append("Boolean: " + isReal.toString() + "\n");
textView.append("Byte: " + isByte.toString() + "\n");
textView.append("UByte: " + isUByte.toString() + "\n");
textView.append("Short: " + isShort.toString() + "\n");
textView.append("UShort: " + isUShort.toString() + "\n");
textView.append("Any Int1: " + isAnyInt1.toString() + "\n");
textView.append("Any Int2: " + isAnyInt2.toString() + "\n");
textView.append("Any String: " + isAnyString.toString() + "\n");
}
}