갤럭시 워치4 버스 어플 만들기 #2 Custom Listview 만들기

2022. 4. 30. 17:10Android

결과화면

 

버스 이름과, 버스 시간 사이에 글씨체 차이가 있기를 바랐기에 Custom Listview를 만들어서 구현했다.

먼저, mainactivity 안에는 listview를 하나 생성해서 넣어둔다.

그리고 그 아래에다가 listview Layout.xml을 생성 구현한다.

List안에 들어갈 item 이미지

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/busID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8106"
            android:textSize="15dp"
            android:layout_marginLeft="10dp"
            android:textColor="@android:color/holo_orange_dark"/>
        <TextView
            android:id="@+id/firstBus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="3정류장 전 / 3분 27초"
            android:textSize="10dp"
            android:layout_marginLeft="10dp"
            android:textColor="@android:color/white"/>
        <TextView
            android:id="@+id/secondBus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="5정류장 전 / 3분 27초"
            android:textSize="10dp"
            android:layout_marginLeft="10dp"
            android:textColor="@android:color/white"/>

    </LinearLayout>

내가 원하는 점 : 버스 넘버, 첫 번째 버스가 오는 시간 , 두 번째 버스가 오는 시간을 원하기 때문에 String은 3개를 넣었다.

 

그 뒤에 뭐.. Adapter 만들고, listview를 채우고...

 

자세한 내용은 Github로 대신하겠다.

 

Github 주소

https://github.com/Bsoyoung/GalaxyWatch_BusApplication.git