[programming]/[Android] 안드로이드

[Android] Widget 안드로이드 위젯 Chronometer 크로노미 실행 소스 코드 예제

codeomni 2019. 11. 18. 23:11
반응형

 

안녕하세요.

이번 포스팅은 안드로이드에서 크로노미터 시계입니다.

시간측정으로 사용됩니다.

안드로이드에서는 기본적으로 다양한 위젯을 지원합니다.

크로노미터 시계는 어플리케이션을 만들 때 유용하게 사용할 수 있습니다.



크로노미터 TextView의 상속을 받습니다.

-java.lang.Object

 android.view.View

    android.widget.TextView

      android.widget.Chronometer

 


TextView의 상속을 받아 background 색상을 설정할 수 있습니다.

 

메소드를 사용할 수 있습니다.

- start() : 시작

- stop() : 정지

- reset() : 초기화

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
<?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"
    tools:context=".MainActivity">
 
    <Chronometer
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cm"
        android:format="시간 측정 : %s"
        android:textSize="25dp"/>
 
</LinearLayout>
 

 

 

 

크로노미터 위젯을 사용한 어플리케이션에 디스플레이입니다.

 기본 속성을 적용했습니다.