지식쌓기/개발-Android 48

Android - get resources by name

R.java 를 참조하지 않고 리소스 얻어오기 int resId = context.getResources().getIdentifier(resName, "string", context.getPackageName()); String str = context.getString(resId); = context.getResouces().getString(resId); int resId = context.getResources().getIdentifier(resName, "drawable", context.getPackageName()); Drawable = context.getResources().getDrawable(redId); getIdentifier 의 첫번째 인자 는 리소스 이름 두번째 인자 "strin..

Android - resultCode from TabActivity

http://groups.google.com/group/android-developers/browse_thread/thread/d97938299660f501/8afafd1b56e646e2?lnk=raot http://www.mail-archive.com/android-developers@googlegroups.com/msg34374.html 위 문제의 해결책 TabActivity 안에 Tab Content로 A Activity 가 있다고 할때 어떤 Caller Activity에서 startActivityOnResult() 로 TabActivity를 호출한 뒤 A Activity에서 아래와 같이 종료하면 (TabActivity가 종료됨) setResult(RESULT_OK, intent); finish()..

Android - MimeType으로 image얻어오기

Android에 번들되어있는 Browser 소스 뒤져보다가 발견한 부분 정확히 mimeType에 해당하는 이미지는 아니고 mimeType을 열수 있는 Application에서 제공하는 이미지를 얻어오는듯 하다(소스를 보아하니 -_-) Intent intent = new Intent(Intent.ACTION_VIEW) intent.setDataAndType(Uri.fromParts("file", "", null), mimeType); PackageManager pm = context.getPackageManager(); List list = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() > 0) { D..

Android - Change Tab Background

TabWidget에서 추가되는 Tab의 Background변경하기 Tab마다 View를 얻어와서 직접 BackgroundDrawable을 지정하고 아래 막대부분은 reflection을 이용하여 꽁수로 바꿔치기 한다 tab_indicator.xml, tab_bar_left.xml, tab_bar_right.xml 내용은 로 정의 private void changeTabWidgetStyle(TabWidget tw){ for (int i = 0; i < tw.getChildCount(); i++) { View v = tw.getChildAt(i); v.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_indicator)); } Field mBot..

Android - TabWidget의 background 변경

http://developer.android.com/guide/tutorials/views/hello-tabwidget.html 위 링크의 TabWidget 예제로 이리저리 TabWidget의 background 변경해본 결과 먼저 background 로 쓸 drawable 파일 준비 일단 tabWidget의 background로 사용할 drawable 파일을 만들었다 물론 그냥 색상을 지정해도 상관없다 ㅋㅋ (걍 이런저런 기능 사용해보기위해) res/drawable/tab_bg.xml 이제 이 background를 적용해 보았다 1. Theme로 적용 styles.xml 만든다 여기서 tabWidgetStyle은 모두 "Widget.TabWidget" style을 사용하도록 하고 background를 ..

Android - Updating UI On UI Thread

Android에서도 UI관련 행위는 UI Thread위에서 해야한다 그렇지 않으면 아래와 같은 Exception이 발생한다 android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created ..... Swing의 SwingUtilities.invokeLater(Runnable r)와 같은 역할을 하는 아래의 방법을 사용하여 해결할수 있다 Activity.runOnUiThread(Runnable action) View.post(Runnable action) View.postDelayed(Runnable action, long delayMillis) Handler.post(Runnable action)

반응형