올해는 머신러닝이다.
ListView 에서 아이템 클릭시 주황색 화면 변경하는 예제 본문
File: res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:listSelector="@android:color/transparent" />
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/empty" />
</LinearLayout>
File: res/layout/item.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" android:padding="10sp" android:background="@drawable/item_selector">
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false" />
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textStyle="bold"
android:padding="7dip"
android:textSize="18sp"
android:layout_toRightOf="@id/checkbox"
android:textColor="@color/black" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/green" />
<item android:state_selected="true" android:drawable="@color/blue" />
<item android:drawable="@color/white" /></selector>
File: res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#ff00</color>
<color name="green">#f0f0</color>
<color name="blue">#f00f</color>
<color name="white">#ffff</color>
<color name="black">#f000</color>
</resources>
'Android > Tip&Tech' 카테고리의 다른 글
overridePendingTransition 설명 (0) | 2011.07.08 |
---|---|
android checkbox 이미지 바꾸기 관련 링크 (0) | 2011.07.07 |
GPS를 활용한 내위치 가져오기 (0) | 2011.07.07 |
파란 개발자 블로그(강력추천) (0) | 2011.07.07 |
반복되는 배경 · 패턴 이미지 만들기 (0) | 2011.07.05 |