이미지뷰.setImageResource(getResources().getIdentifier("img파일명","drawable","패키지명"));
여기서 img파일명은 확장자를 뺀 것이다. 예를들어 icon.png 라면 icon만 들어가야 함.
ex) memberView.setImageResource(getResources().getIdentifier("icon","drawable","com.android.sample"));
'프로그래밍 > 안드로이드' 카테고리의 다른 글
| [android] 이미지 세팅(String을 Int로) (0) | 2011/01/14 |
|---|---|
| [android] Intent 활용 (0) | 2011/01/14 |
| [android][ImageButton] 이미지버튼 클릭시 이미지 바꾸기 (0) | 2011/01/14 |
연락처 Intent
- 연락처 조회
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/" + String.valueOf(contact.getId()))); startActivity(intent);
- 연락처 등록
intent = new Intent(Intent.ACTION_INSERT, Uri.parse("content://contacts/people")); startActivity(intent);
- 연락처 수정
intent = new Intent(Intent.ACTION_EDIT, Uri.parse("content://contacts/people/" + String.valueOf(contact.getId()))); startActivity(intent);
- 연락처 삭제
intent = new Intent(Intent.ACTION_DELETE, Uri.parse("content://contacts/people/" + String.valueOf(contact.getId()))); startActivity(intent);
전화 Intent
- 권한 설정 (AndroidManifest.xml)
전화 걸기 : CALL_PHONE = "android.permission.CALL_PHONE" 긴급 통화 : CALL_PRIVILEGED = "android.permission.CALL_PRIVILEGED" 폰 상태 읽기 : READ_PHONE_STATE = "android.permission.READ_PHONE_STATE" 폰 상태 수정 : MODIFY_PHONE_STATE = "android.permission.MODIFY_PHONE_STATE" 브로드케스팅 수신 : PROCESS_OUTGOING_CALLS = "android.permission.PROCESS_OUTGOING_CALLS" 전화 걸기 이전 : ACTION_NEW_OUTGOING_CALL = "android.intent.action.NEW_OUTGOING_CALL"
- 전화걸기 화면
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + TelNumber)); startActivity(intent);
- 전화걸기
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + TelNumber)); startActivity(intent);
SMS Intent
- 권한 설정 (AndroidManifest.xml)
수신 모니터링 : RECEIVE_SMS = "android.permission.RECEIVE_SMS" 읽기 가능 : READ_SMS = "android.permission.READ_SMS" 발송 가능 : SEND_SMS = "android.permission.SEND_SMS" SMS Provider로 전송 : WRITE_SMS = "android.permission.WRITE_SMS" : BROADCAST_SMS = "android.permission.BROADCAST_SMS"
- SMS 발송 화면
Intent intent = new Intent(Intent.ACTION_VIEW); intent.putExtra("sms_body", "The SMS text"); startActivity(intent);
- SMS 보내기
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + contact.getHandphone())); intent.putExtra("sms_body", "The SMS text"); startActivity(intent); 이메일 Intent
- 이메일 발송 화면
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + contact.getEmail())); startActivity(intent);
브라우저 Intent
- Browser에서 URL 호출하기
new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/")); startActivity(intent);
- 브라우저에서 검색
Intent intent = new Intent(Intent.ACT ION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, "검색어"); startActivity(intent);
지도 Intent
- 지도 보기
Uri uri = Uri.parse ("geo: 38.00, -35.03"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
안드로이드 마켓 Intent
- 안드로이드 마켓에서 Apps 검색
Uri uri = Uri.parse("market://search?q=pname:전제_패키지_명"); //--- 예) market://search?q=pname:com.jopenbusiness.android.smartsearch Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
- 안드로이드 마켓의 App 상세 화면
Uri uri = Uri.parse("market://details?id=전제_패키지_명"); //--- 예) market://details?id=com.jopenbusiness.android.smartsearch Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
갤럭시S의 Intent
- 패키지명과 클래스명으로 App 호출
intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName("패키지명", "전체_클래스명")); startActivity(intent);
- 전화, SMS
-
- 전화번호부 : com.android.contacts, com.sec.android.app.contacts.PhoneBookTopMenuActivity
- 전화 : com.sec.android.app.dialertab, com.sec.android.app.dialertab.DialerTabActivity
- 최근기록 : com.sec.android.app.dialertab, com.sec.android.app.dialertab.DialerTabDialerActivity
- 메시지 : com.sec.mms, com.sec.mms.Mms
- 이메일 : com.android.email, com.android.email.activity.Welcome
- 일정 : com.android.calendar, com.android.calendar.LaunchActivity
- 인터넷 : com.android.browser, com.android.browser.BrowserActivity
- Google의 Android용 앱
-
- 검색 : com.google.android.googlequicksearchbox, com.google.android.googlequicksearchbox.SearchActivity
- 음성 검색 : com.google.android.voicesearch, com.google.android.voicesearch.RecognitionActivity
- Gmail : com.google.android.gm, com.google.android.gm.ConversationListActivityGmail
- 지도 : com.google.android.apps.maps, com.google.android.maps.MapsActivity
- 위치찾기 : com.google.android.apps.maps, com.google.android.maps.LatitudeActivity
- YouTube : com.google.android.youtube, com.google.android.youtube.HomeActivity
- 토크 : com.google.android.talk, com.google.android.talk.SigningInActivity
- Goggles : com.google.android.apps.unveil, com.google.android.apps.unveil.CaptureActivity
- Google 번역 : com.google.android.apps.translate, com.google.android.apps.translate.HomeActivity
- Reader : com.google.android.apps.reader, com.google.android.apps.unveil.CaptureActivity
- Voice : com.google.android.apps.googlevoice, com.google.android.apps.googlevoice.SplashActivity
- Google 별지도 : com.google.android.stardroid, com.google.android.stardroid.activities.SplashScreenActivity
- 카메라 : com.sec.android.app.camera, com.sec.android.app.camera.Camera
- TV : com.sec.android.app.dmb, com.sec.android.app.dmb.activity.DMBFullScreenView
- Android 관리
-
- 환경 설정 : com.android.settings, com.android.settings.Settings
- 작업 관리자 : com.sec.android.app.controlpanel, com.sec.android.app.controlpanel.activity.JobManagerActivity
- 마켓 : com.android.vending, com.android.vending.AssetBrowserActivity
'프로그래밍 > 안드로이드' 카테고리의 다른 글
| [android] 이미지 세팅(String을 Int로) (0) | 2011/01/14 |
|---|---|
| [android] Intent 활용 (0) | 2011/01/14 |
| [android][ImageButton] 이미지버튼 클릭시 이미지 바꾸기 (0) | 2011/01/14 |
이미지 버튼을 누르면 이미지(그림)를 바꾸는 방법.
Android SDK : http://developer.android.com/reference/android/widget/ImageButton.html
| <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/button_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/button_focused" /> <!-- focused --> <item android:drawable="@drawable/button_normal" /> <!-- default --> </selector> |
위소스를 보면 1) 눌렀을때, 2) 포커스 되었을때, 3) 보통 상태. 각 상황에 버튼의 이미지를 바꿀수 있도록 되어 있다.
1. SDK 조언대로, 'res'폴더 하위에 'drawable'폴더에 img_btn_test.xml파일을 만든다. (여기서 .xml파일명은 임의로 해도됨.)
(기본적으로 drawable이 생성되어 있지 않다면, 폴더 직접 생성할것)
2. 그리고 img_btn_test.xml 파일에 위 표안에 있는 소스를 복사한다.
(.png 파일명은 자신의 파일 명과 일치 시킬것. 알아서 융통성있게 수정하시오.)
3. 세 가지 drawable 폴더중에 기본이 되는 drawable-mdpi폴더에 각각 상태에 따라 바뀌길 바라는 이미지 3개 .png 파일을 추가한다.
(세가지 모두 drawable에 각각 3가지 아이콘을 중복해서 넣어도 되는데.. 굳이 그렇게 할 필요가.. 있을가 싶당. 회색님도 그렇게 하지 말라고 하셨음. drawable-hdpi에 넣어도되고요~)
4. 실제 ImageButton이 있는 .xml파일에서 ImageButton이 속성값을 수정해야 한다.
<ImageButton
android:id="@+id/Image_Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_btn_test" >
</ImageButton>
이처럼 background 속성에 drawable 폴더안에 만들었던 .xml파일 명을 적어준다.
※ 참고로 3가지 속성을 전부다 사용하지 않아도 된다. 사용하지 않는 state_xxx 에 =false값을 넣으면 됨.
'프로그래밍 > 안드로이드' 카테고리의 다른 글
| [android] 이미지 세팅(String을 Int로) (0) | 2011/01/14 |
|---|---|
| [android] Intent 활용 (0) | 2011/01/14 |
| [android][ImageButton] 이미지버튼 클릭시 이미지 바꾸기 (0) | 2011/01/14 |


