기술참고자료/Linux | 2011. 5. 3. 23:56
[리눅스] netstat 명령으로 포트확인하기 (0) | 2011.05.10 |
---|---|
[리눅스] phpMyAdmin, ‘Error #2002 – The server is not responding’, and OS X 10.x (0) | 2011.05.09 |
top명령어와 사용방법 (0) | 2011.03.22 |
우분투 10.04 한글깨짐현상 해결방법 (0) | 2011.03.17 |
[CentOS] 한글지원 패키지 추가 및 한글설정 (0) | 2011.03.09 |
기술참고자료/JAVA | 2011. 5. 2. 13:33
샘플 코드
List<TestBean> testList = new ArrayList<TestBean>(testMap.values());
Comparator<TestBean> c = Collections.reversOrder();
Collections.sort(testList, c);
위의 예처럼
1. 먼저 대상 맵의 value 만을 가지고 리스트를 하나 만든다.
2. 어떻게 비교할것인지 정한다 (여기선 내림차순)
3. Collections.sort 메소드에 위에서 만든 대상 리스트와 비교 방법을 넣어준다.
이렇게 하면 리스트가 정렬되어있다
여기서 리스트가 직접 정의한 클래스를 대상으로 비교를 해야하는 경우에는
해당 클래스가 Comparable 인터페이스를 구현하고, compareTo() 메소드를 오버라이드 하고 있어야 한다
위의 예를 들면(여기서는 해당 객체의 count를 가지고 비교를 하려고 한다)
요렇게 되어있으면 된다!!public TestBean implements Comparable{
private int count;
public int compareTo(Object arg0){
TestBean comparer = (TestBean) arg0;
return this.count - comparer.count;
}
}
출처 : http://blog.daum.net/_blog/BlogTypeView.do?
blogid=0QJho&articleno=31&_bloghome_menu=recenttext#ajax_history_home
How to add SVN plugin for STS ? (0) | 2011.12.20 |
---|---|
[JAVA] XML 직렬화도구 - Simple Framework (1) | 2011.06.21 |
HttpClient의 심플한 사용 (0) | 2011.03.21 |
List Sort Sample Using Comparator<T> Interface (0) | 2011.03.17 |
DOM Parser vs SAX Parser (0) | 2011.03.17 |
기술참고자료/Android | 2011. 4. 28. 09:56
진저브레드관련 - Android App 개발시 주의사항요청(CTS 승인이슈건) (0) | 2011.05.06 |
---|---|
[안드로이드] Disable scroll view action (0) | 2011.05.04 |
View에 백그라운드 반복설정 (0) | 2011.04.20 |
<TextView>에서의 줄간격 설정하기 (0) | 2011.04.20 |
<supports-screens> Guide (1) | 2011.04.19 |
기술참고자료/Android | 2011. 4. 20. 10:56
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/dot_line"
android:tileMode="repeat"
/>
<EditText
android:id="@+id/edit_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/edit_title"
android:background="@drawable/letter_background"
android:gravity="top"
android:lineSpacingExtra="20px"
android:minHeight ="200px"
/>
[안드로이드] Disable scroll view action (0) | 2011.05.04 |
---|---|
SKT - 안드로이드 출시 단말별 해상도 (0) | 2011.04.28 |
<TextView>에서의 줄간격 설정하기 (0) | 2011.04.20 |
<supports-screens> Guide (1) | 2011.04.19 |
<support-screen> (0) | 2011.04.19 |
기술참고자료/Android | 2011. 4. 20. 10:41
<?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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/aticle_content" /> </LinearLayout> |
<?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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/aticle_content" android:lineSpacingExtra="15dip" /> </LinearLayout> |
<?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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/aticle_content" android:lineSpacingMultiplier="2.5" /> </LinearLayout> |
SKT - 안드로이드 출시 단말별 해상도 (0) | 2011.04.28 |
---|---|
View에 백그라운드 반복설정 (0) | 2011.04.20 |
<supports-screens> Guide (1) | 2011.04.19 |
<support-screen> (0) | 2011.04.19 |
SIM의 IMSI값 읽어오기 (0) | 2011.04.19 |