기본 콘텐츠로 건너뛰기

[android] 액션 버튼 아이콘 변경 (Action item icon)


invalidateOptionsMenu(); 를 사용하여 onPrepareOptionsMenu함수를 호출 할 수 있다는 점을 이용.

bchange의 여부에 따라서 아이콘을 변경할 수 있다.


1
2
3
4
5
6
7
8
9
10
11
12
@Override
    public void onPrepareOptionsMenu(Menu menu) {
        if(bchange)
        {
            menu.findItem(R.id.menu_test).setIcon(R.drawable.btngrid);
        }
        else
        {
            menu.findItem(R.id.menu_test).setIcon(R.drawable.btnlist);
        }
        super.onPrepareOptionsMenu(menu);
    }
cs


댓글

댓글 쓰기

이 블로그의 인기 게시물

[android] url scheme 사용하기 (웹에서 앱 호출 및 앱에서 앱 호출)

[호출될 앱] 다른 앱이나 웹에서 호출될 앱의 AndroidManifest.xml 파일을 열어 원하는 activity에 아래와 같이 빨간 부분을 추가 한다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <activity             android:name= ".testUrlScheme"             android:label= "@string/app_name" >             <intent-filter>                 <action android:name= "android.intent.action.MAIN"  />                 <category android:name= "android.intent.category.LAUNCHER"  />             </intent-filter>             ...

[ios] image set Retina 4-inch가 안먹을 때

Image set을 이용하여 기기별로 이미지를 각각 지정하여도 iphone5/5s에서 Retina 4-inch의 이미지가 적용이 되지 않고 2x의 이미지가 적용되는 현상이 발생했다. 적용되지 않았던 원인은!! Deployment Target을 6.0으로 지정했기 때문에!!! 7.0으로 변경하니 제대로 적용되었다. 7.0부터 적용되며 그 이하에서는 Retina 4-inch대신 2x이미지가 적용되는듯 하다.

[android] textview 옆에 image 추가하기.

xml페이지에 다음과 같이 구현 android:drawableLeft  : 텍스트 왼쪽에 이미지 추가. android:drawableRight : 텍스트 오른쪽에 이미지 추가. Left, Right 외에도 top, bottom, start, end가 있다. android:drawablePadding : 이미지의 공간 (텍스트와 이미지 사이의 간격을 띄울 때 주로 사용.) <TextView           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:text="오른쪽에 마크"           android:drawableRight="@drawable/mark"           android:drawablePadding="10dp" />