1) 조회 결과를 저장할 Value Object Class 선언
public class Addressbook {
private String name;
private String phnnumber;
public void setPhnnumber(String phnnumber) {
this.phnnumber = phnnumber;
}
public String getPhnnumber() {
return phnnumber;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
2) Contacts 조회 Method Sample
protected Addressbook[] getFriendsfromAddressBook()
{
String[] projection = new String[] { Phone.DISPLAY_NAME, Phone.NUMBER };
Cursor c = getContentResolver().query( Phone.CONTENT_URI, projection, null, null, null);
Addressbook[] addressfriend = new Addressbook[ c.getCount() ];
c.moveToFirst();
int idx = 0;
String bookname = null;
String booknum = null;
try {
if ( ! c.isAfterLast() )
{
do
{
bookname = c.getString( 0 );
booknum = c.getString( 1 );
addressfriend[idx] = new Addressbook();
addressfriend[idx].setName( bookname );
addressfriend[idx].setPhnnumber( booknum );
idx++;
} while ( c.moveToNext() );
}
} catch (Exception e ) {
showToastMsg ( "주소록 정보를 가져올 수 없습니다.\n" + e.toString());
return null;
}
finally {
c.close();
}
return addressfriend;
}
Docker, WSL, Kubernetes, GitLab CI, Nexus, SonarQube, Prometheus/Grafana, Ollama 등 개발·DevOps 환경 구축 방법과 오류 해결 팁, 그리고 직접 만든 Android 앱 개발 기록을 정리한 블로그입니다.
2011년 12월 1일 목요일
Android 용 Eclipse 환경 설정
1) eclipse 3.5 version 이상 download
URL : http://www.eclipse.org/downloads/
2) android 용 SDK download
URL : http://developer.android.com/sdk/index.html
3) eclipse 실행 후, Android 용 ADT (Android Development Tool) Install
eclipse -> help -> Install New Software : https://dl-ssl.google.com/android/eclipse/.
4) eclipse -> windows -> preferences -> android 에서 Android SDK 의 Home 디렉토리 설정
5) eclipse -> windows -> Android SDK and AVD Manager -> Available Packages 에서 원하는 Package 선택 후, Install
URL : http://www.eclipse.org/downloads/
2) android 용 SDK download
URL : http://developer.android.com/sdk/index.html
3) eclipse 실행 후, Android 용 ADT (Android Development Tool) Install
eclipse -> help -> Install New Software : https://dl-ssl.google.com/android/eclipse/.
4) eclipse -> windows -> preferences -> android 에서 Android SDK 의 Home 디렉토리 설정
5) eclipse -> windows -> Android SDK and AVD Manager -> Available Packages 에서 원하는 Package 선택 후, Install
Android Widget 생성
1) AndroidManifest.xml 에 AppWidget 선언
<receiver android:name="phoneinfoWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/phoneinfo_provider" />
</receiver>
2) 1)에서 정의한 android:resource="@xml/phoneinfo_provider" 의 설정에 따라 /res/xml 디렉토리에 phoneinfo_provider.xml 파일을 생성하여 AppWidgetProviderInfo Meta Data 추가
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="30000"
android:initialLayout="@layout/phoneinfo_widget"
android:configure="com.shlee.pi.PhoneInfoWidgetConfigure" >
</appwidget-provider>
3) App Widget Layout 선언 (phoneinfo_widget.xml)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_widget"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<TextView android:id="@+id/label_attr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#FFAA00"/>
<TextView android:id="@+id/value_attr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/label_attr"
android:gravity="right"
android:layout_gravity="right"
android:textSize="14sp"
android:textColor="#FFF" />
</RelativeLayout>
<receiver android:name="phoneinfoWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/phoneinfo_provider" />
</receiver>
2) 1)에서 정의한 android:resource="@xml/phoneinfo_provider" 의 설정에 따라 /res/xml 디렉토리에 phoneinfo_provider.xml 파일을 생성하여 AppWidgetProviderInfo Meta Data 추가
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="30000"
android:initialLayout="@layout/phoneinfo_widget"
android:configure="com.shlee.pi.PhoneInfoWidgetConfigure" >
</appwidget-provider>
3) App Widget Layout 선언 (phoneinfo_widget.xml)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_widget"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<TextView android:id="@+id/label_attr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#FFAA00"/>
<TextView android:id="@+id/value_attr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/label_attr"
android:gravity="right"
android:layout_gravity="right"
android:textSize="14sp"
android:textColor="#FFF" />
</RelativeLayout>
Windows XP 에서 한글 전환 오류 해결방법
Windows XP 의 노트패드 등에서 한글 전환등이 안되서,
며칠간 윈도우 업데이트부터 해서 이것저것 설정을 바꿔도 안되더니만...
아래 reg 파일을 실행하여 Registry 를 update 하니 며칠간의 고민이 바로 해결되었음..ㅎ
아래 내용을 노트패드 등에서 파일명을 hotkey.reg 로 하여 붙여넣은 후,
실행하여 registry 를 업뎃~!! ^^
==== 아래 =========================================
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Input Method]
"Show Status"="1"
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys]
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000010]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000011]
"Key Modifiers"=hex:04,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000012]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:be,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000070]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000071]
"Key Modifiers"=hex:04,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000072]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:bc,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000200]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:47,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000201]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:4b,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000202]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:4c,00,00,00
며칠간 윈도우 업데이트부터 해서 이것저것 설정을 바꿔도 안되더니만...
아래 reg 파일을 실행하여 Registry 를 update 하니 며칠간의 고민이 바로 해결되었음..ㅎ
아래 내용을 노트패드 등에서 파일명을 hotkey.reg 로 하여 붙여넣은 후,
실행하여 registry 를 업뎃~!! ^^
==== 아래 =========================================
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Input Method]
"Show Status"="1"
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys]
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000010]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000011]
"Key Modifiers"=hex:04,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000012]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:be,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000070]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000071]
"Key Modifiers"=hex:04,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000072]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:bc,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000200]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:47,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000201]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:4b,00,00,00
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000202]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:4c,00,00,00
2011년 4월 3일 일요일
사칙 연산자 찾기 게임
기존 간단히 만들어 놓은거 조금 수정해서 마켓에 올려놓은 게임..
market://details?id=com.shlee.findOperator
http://www.appbrain.com/app/find-operator-game/com.shlee.findOperator
game for finding arithmetic operator in simple equation..
이넘도 다운로드 좀 되려나? ㅋ
market://details?id=com.shlee.findOperator
http://www.appbrain.com/app/find-operator-game/com.shlee.findOperator
game for finding arithmetic operator in simple equation..
이넘도 다운로드 좀 되려나? ㅋ
2011년 4월 2일 토요일
[TIP] Table Layout 의 Width 균일하게 설정...
결론만 정리하면 Key 는
android:layout_width="0dip" 와 android:layout_weight="1" 였음..
설정 예제는..
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="5px"
android:gravity="bottom"
android:stretchColumns="0,1"
>
<TableRow>
<ImageButton
android:id="@+id/n11"
android:layout_column="0"
android:layout_width="0dip"
android:layout_height="38dip"
android:scaleType="fitXY"
android:layout_weight="1"
android:background="#ffffff"
android:src="@drawable/plusbtn"
/>
적용하니.. 원하는대로 버튼의 가로 크기가 균일하게 나옴.. ^^
android:layout_width="0dip" 와 android:layout_weight="1" 였음..
설정 예제는..
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="5px"
android:gravity="bottom"
android:stretchColumns="0,1"
>
<TableRow>
<ImageButton
android:id="@+id/n11"
android:layout_column="0"
android:layout_width="0dip"
android:layout_height="38dip"
android:scaleType="fitXY"
android:layout_weight="1"
android:background="#ffffff"
android:src="@drawable/plusbtn"
/>
적용하니.. 원하는대로 버튼의 가로 크기가 균일하게 나옴.. ^^
왜 이렇게 하면 폭이 같아지나요?
LinearLayout과 TableRow는 자식 뷰의 크기를 먼저 정한 뒤 남는 공간을 layout_weight 비율대로 나눠 줍니다. layout_width를 0dip으로 두면 각 버튼의 기본 폭이 0이 되어, 남는 공간 전체가 weight 비율(여기서는 모두 1)대로 분배됩니다. 그래서 버튼 안의 이미지나 글자 크기와 상관없이 같은 폭이 됩니다. 반대로 wrap_content로 두면 내용물 크기가 먼저 반영되어 폭이 서로 달라질 수 있습니다.
확인 방법
- 버튼 개수를 늘리거나 이미지 크기를 다르게 바꿔도 폭이 같은지 에뮬레이터에서 확인합니다.
- weight를 하나만 2로 바꾸면 그 버튼이 다른 버튼의 두 배 폭을 차지하는지 확인해 비율 분배를 이해할 수 있습니다.
요즘 방식으로 쓴다면
- fill_parent는 API 8부터 match_parent로 대체되었으므로 새 코드에서는 match_parent를 사용합니다. dip과 dp는 같은 단위입니다.
- 한 줄에 같은 폭으로 나열하려면 가로 방향 LinearLayout에 자식 폭 0dp와 layout_weight 1을 주는 방식을 그대로 쓸 수 있습니다.
- 행과 열이 있는 격자 형태라면 GridLayout(API 21 이상)의 layout_columnWeight, 또는 ConstraintLayout의 가로 체인(chainStyle spread)과 0dp 폭 조합을 고려할 수 있습니다.
이 글은 2011년 기준으로 작성되었고, 위 보강 설명은 2026년 11월에 추가했습니다.
English version: Android TableLayout: Make Button Widths Equal with layout_weight
2011년 3월 25일 금요일
[Info] Debug Certificate expired on YY. MM. DD ...
오랜만에 안드로이드 코드좀 보려고... eclipse 를 기동하고 전체 build 를 한번 했더니..
"Error generating final archive: Debug Certificate expired on 11. 3. 23 오후 2:01"
와 같은 오류가 줄줄이 발생..하여 대략 난감.. T.T
구글을 뒤져....
C:\Documents and Settings\<user>\.android\debug.keystore 파일을 삭제하고 다시 Build...
문제 해결..!!
음.. debug.keystore.. 이넘의 만기가 1년이라는데.. 벌써 안드로이를 위한 Eclipse 설치한지가
벌써 1년이 되었나? 흐음..
암튼.. Google Map API 사용하기 위해 debug.keystore 를 사용한 기억이 어렴풋이..
근데....내가 keystore 를 만든 기억이 없어 찾아보니 eclipse 가 필요할때..
자동으로 만들어 준단다..
암튼.. apk 파일 생성시 서명을 넣기 위해 필요한 넘이라는군..
자동으로 만들어 주니.. 중요한 넘이라는걸 모르고 있었군.. 쩝..
"Error generating final archive: Debug Certificate expired on 11. 3. 23 오후 2:01"
와 같은 오류가 줄줄이 발생..하여 대략 난감.. T.T
구글을 뒤져....
C:\Documents and Settings\<user>\.android\debug.keystore 파일을 삭제하고 다시 Build...
문제 해결..!!
음.. debug.keystore.. 이넘의 만기가 1년이라는데.. 벌써 안드로이를 위한 Eclipse 설치한지가
벌써 1년이 되었나? 흐음..
암튼.. Google Map API 사용하기 위해 debug.keystore 를 사용한 기억이 어렴풋이..
근데....내가 keystore 를 만든 기억이 없어 찾아보니 eclipse 가 필요할때..
자동으로 만들어 준단다..
암튼.. apk 파일 생성시 서명을 넣기 위해 필요한 넘이라는군..
자동으로 만들어 주니.. 중요한 넘이라는걸 모르고 있었군.. 쩝..
피드 구독하기:
글 (Atom)
