java소스
drawer_open.xml
drawer_close.xml
위 소스는 ADW.Launcher를 기초로 했음. <설명>독바의 Application Drawer 버튼의 이미지를 동적으로 변경을 하기 위해 xml로 되어 있던 것을 java 소스상에서 변경을 할수 있게끔 변경했음.
int stateChecked = android.R.attr.state_checked; int stateFocused = android.R.attr.state_focused; int statePressed = android.R.attr.state_pressed; int stateEnabled = android.R.attr.state_enabled; int stateWindowFocused = android.R.attr.state_window_focused; StateListDrawable dr_open = (StateListDrawable)getResources().getDrawable(R.drawable.drawer_close); dr_open.addState(new int[]{-stateWindowFocused, stateEnabled}, new BitmapDrawable(getResources(), filePath + "ic_tray_expand.png" )); dr_open.addState(new int[]{statePressed}, new BitmapDrawable(getResources(), filePath + "ic_tray_expand_pressed.png" )); dr_open.addState(new int[]{stateFocused, stateEnabled}, new BitmapDrawable(getResources(), filePath + "ic_tray_expand_selected.png" )); dr_open.addState(new int[]{stateEnabled}, new BitmapDrawable(getResources(), filePath + "ic_tray_expand.png" )); dr_open.addState(new int[]{stateFocused}, new BitmapDrawable(getResources(), filePath + "ic_tray_expand_selected.png" )); StateListDrawable dr_close = (StateListDrawable)getResources().getDrawable(R.drawable.drawer_open); dr_close.addState(new int[]{-stateWindowFocused, stateEnabled}, new BitmapDrawable(getResources(), filePath + "ic_tray_collapse.png" )); dr_close.addState(new int[]{statePressed}, new BitmapDrawable(getResources(), filePath + "ic_tray_collapse_pressed.png" )); dr_close.addState(new int[]{stateFocused, stateEnabled}, new BitmapDrawable(getResources(), filePath + "ic_tray_collapse_selected.png" )); dr_close.addState(new int[]{stateEnabled}, new BitmapDrawable(getResources(), filePath + "ic_tray_collapse.png" )); dr_close.addState(new int[]{stateFocused}, new BitmapDrawable(getResources(), filePath + "ic_tray_collapse_selected.png" )); Drawable drawable[] = new Drawable[]{dr_open, dr_close}; TransitionDrawable tranDrawable = new TransitionDrawable(drawable); mHandleView.setImageDrawable(tranDrawable);
drawer_open.xml
drawer_close.xml
위 소스는 ADW.Launcher를 기초로 했음. <설명>독바의 Application Drawer 버튼의 이미지를 동적으로 변경을 하기 위해 xml로 되어 있던 것을 java 소스상에서 변경을 할수 있게끔 변경했음.