[android-developers] Re: Coloring Default Buttons - color filter only on unfocused state
I see a similar solution on stackoverflow: http://stackoverflow.com/questions/2065430/fixed-android-detecting-focus-pressed-color/2189757#2189757 but I have some concerns with that solution, mainly what if the OS changes the graphic of the default button? Since the normal unfocused/ unpressed graphic is now hardcoded into the app, it would break the flow. Maybe can someone comment on whether it would be good or bad practice to hardcode the default graphic into the app? What are the chances of the OS completely changing the graphic? Thanks! On Feb 2, 4:57 pm, RLo wrote: > Also tried this: > > StateListDrawable sd = new StateListDrawable(); > int stateFocused = android.R.attr.state_focused; > int statePressed = android.R.attr.state_pressed; > Drawable norm = this.getResources().getDrawable > (android.R.drawable.btn_default); > sd.addState(new int[]{statePressed}, norm); > sd.addState(new int[]{stateFocused}, norm); > norm.mutate().setColorFilter(Color.parseColor(this.getString > (R.color.button_blue)), Mode.MULTIPLY); > sd.addState(new int[]{-stateFocused, -statePressed}, norm); > > myButton.setBackgroundDrawable(sd); > > Whichseems like it would make sense. But i get nullpointer > exception because turns out I can't mutate an android.R.drawable... > > Any ideas?? Help!! > > On Feb 2, 4:23 pm, RLo wrote: > > > Hi All, > > > I want to buttons of different colors, but I want to do so while using > > the default button background resource in order to preserve the > > onfocus and onclick states. This is because I want to use the default > > highlight color of the OS for my app, which is NOT always orange (HTC > > Sense makes it green). > > > I found that adding a color filter to the button's background drawable > > works great (in this case, blue): > > > myButton.getBackground().setColorFilter(Color.parseColor(this.getString > > (R.color.button_blue)), Mode.MULTIPLY); > > > BUT, when the button is focused or clicked, it turns a nasty > > orange_blue because it mixes the color filter with the orange of the > > background drawable. > > > I want to ONLY set this color filter for the unfocused/unclicked nine- > > patch drawable within the default button's statelistdrawable. > > > I tried: > > > myButton.getBackground().getCurrent().setColorFilter(Color.parseColor > > (this.getString(R.color.button_blue)), Mode.MULTIPLY); > > > But this does no coloring at all. I'm not sure how else to do this. > > > Any help please? Thanks very much!! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Coloring Default Buttons - color filter only on unfocused state
Also tried this: StateListDrawable sd = new StateListDrawable(); int stateFocused = android.R.attr.state_focused; int statePressed = android.R.attr.state_pressed; Drawable norm = this.getResources().getDrawable (android.R.drawable.btn_default); sd.addState(new int[]{statePressed}, norm); sd.addState(new int[]{stateFocused}, norm); norm.mutate().setColorFilter(Color.parseColor(this.getString (R.color.button_blue)), Mode.MULTIPLY); sd.addState(new int[]{-stateFocused, -statePressed}, norm); myButton.setBackgroundDrawable(sd); Whichseems like it would make sense. But i get nullpointer exception because turns out I can't mutate an android.R.drawable... Any ideas?? Help!! On Feb 2, 4:23 pm, RLo wrote: > Hi All, > > I want to buttons of different colors, but I want to do so while using > the default button background resource in order to preserve the > onfocus and onclick states. This is because I want to use the default > highlight color of the OS for my app, which is NOT always orange (HTC > Sense makes it green). > > I found that adding a color filter to the button's background drawable > works great (in this case, blue): > > myButton.getBackground().setColorFilter(Color.parseColor(this.getString > (R.color.button_blue)), Mode.MULTIPLY); > > BUT, when the button is focused or clicked, it turns a nasty > orange_blue because it mixes the color filter with the orange of the > background drawable. > > I want to ONLY set this color filter for the unfocused/unclicked nine- > patch drawable within the default button's statelistdrawable. > > I tried: > > myButton.getBackground().getCurrent().setColorFilter(Color.parseColor > (this.getString(R.color.button_blue)), Mode.MULTIPLY); > > But this does no coloring at all. I'm not sure how else to do this. > > Any help please? Thanks very much!! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Coloring Default Buttons - color filter only on unfocused state
Hi All, I want to buttons of different colors, but I want to do so while using the default button background resource in order to preserve the onfocus and onclick states. This is because I want to use the default highlight color of the OS for my app, which is NOT always orange (HTC Sense makes it green). I found that adding a color filter to the button's background drawable works great (in this case, blue): myButton.getBackground().setColorFilter(Color.parseColor(this.getString (R.color.button_blue)), Mode.MULTIPLY); BUT, when the button is focused or clicked, it turns a nasty orange_blue because it mixes the color filter with the orange of the background drawable. I want to ONLY set this color filter for the unfocused/unclicked nine- patch drawable within the default button's statelistdrawable. I tried: myButton.getBackground().getCurrent().setColorFilter(Color.parseColor (this.getString(R.color.button_blue)), Mode.MULTIPLY); But this does no coloring at all. I'm not sure how else to do this. Any help please? Thanks very much!! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Extending TabHost - override focus handling
wow well, i guess i solved my own problem. instead of overriding the tabhost's implementation of dispatchkeyevent, i implemented my logic in my extension of tab activity and it works! On Jan 12, 12:55 pm, RLo wrote: > Hi All, > > I have a tabhost with the tabwidget on the bottom (not hard to do, > just put the tabcontent above the tabs in the tab xml). However, I > noticed the order of focus is off (since the tabhost is hardcoded to > be on the top). I'd like to change 2 things in how the tabhost > handles focus order: > > 1. change the tabwidget's position in the focus order (to be on > bottom, not top) > 2. allow left and right focus commands to change the tabs from > anywhere (not just when the tabwidget is focused) > > For #2 above, see HTC's sense toolbars for an example (built into the > hero, such as the albums or people native apps). > > I think I can achieve both of these by overriding tabhost's > dispatchKeyEvent (code at bottom), I would just change the current > implementation to handle KEYCODE_DPAD_DOWN instead of KEYCODE_DPAD_UP, > and then add in left and right detection as well. > > How can I override JUST this method in the tabhost implementation? > I'm not a Java pro, so this could be relatively simple and I'm just > clueless how to do it :) > > Thanks much! > > -- > @Override > public boolean dispatchKeyEvent(KeyEvent event) { > final boolean handled = super.dispatchKeyEvent(event); > > // unhandled key ups change focus to tab indicator for > embedded activities > // when there is nothing that will take focus from default > focus searching > if (!handled > && (event.getAction() == KeyEvent.ACTION_DOWN) > && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP) > && (mCurrentView.isRootNamespace()) > && (mCurrentView.hasFocus()) > && (mCurrentView.findFocus().focusSearch > (View.FOCUS_UP) == null)) { > mTabWidget.getChildAt(mCurrentTab).requestFocus(); > playSoundEffect(SoundEffectConstants.NAVIGATION_UP); > return true; > } > return handled; > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Extending TabHost - override focus handling
Hi All, I have a tabhost with the tabwidget on the bottom (not hard to do, just put the tabcontent above the tabs in the tab xml). However, I noticed the order of focus is off (since the tabhost is hardcoded to be on the top). I'd like to change 2 things in how the tabhost handles focus order: 1. change the tabwidget's position in the focus order (to be on bottom, not top) 2. allow left and right focus commands to change the tabs from anywhere (not just when the tabwidget is focused) For #2 above, see HTC's sense toolbars for an example (built into the hero, such as the albums or people native apps). I think I can achieve both of these by overriding tabhost's dispatchKeyEvent (code at bottom), I would just change the current implementation to handle KEYCODE_DPAD_DOWN instead of KEYCODE_DPAD_UP, and then add in left and right detection as well. How can I override JUST this method in the tabhost implementation? I'm not a Java pro, so this could be relatively simple and I'm just clueless how to do it :) Thanks much! -- @Override public boolean dispatchKeyEvent(KeyEvent event) { final boolean handled = super.dispatchKeyEvent(event); // unhandled key ups change focus to tab indicator for embedded activities // when there is nothing that will take focus from default focus searching if (!handled && (event.getAction() == KeyEvent.ACTION_DOWN) && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP) && (mCurrentView.isRootNamespace()) && (mCurrentView.hasFocus()) && (mCurrentView.findFocus().focusSearch (View.FOCUS_UP) == null)) { mTabWidget.getChildAt(mCurrentTab).requestFocus(); playSoundEffect(SoundEffectConstants.NAVIGATION_UP); return true; } return handled; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Webview Zoom Picker
Hi all, I'm using the webview and would like to add functionality to zoom in and out. The zoompicker (used in the browser) is most natural, but when I try to call it using invokeZoomPicker(), nothing happens. I've tried calling it in many different ways, but it doesn't show up. Anyone know how to use this widget? Thank you! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: ListView with different images for each line
dude. you are awesome. works perfectly, thank you! On Apr 22, 6:11 pm, xingye <[EMAIL PROTECTED]> wrote: > you can use viewbinder > seehttp://code.google.com/p/sharepath/ Inbox.java > > On 4月23日, 上午7时50分, RLo <[EMAIL PROTECTED]> wrote: > > > I'm creating a sort of "buddy list", using a ListView that draws > > information from a local sqlite database into a cursor and sets the > > ListView using a SimpleCursorAdapter. > > > The Problem: > > I want to add icons for each entry in the buddy list, imagine > > something like Google Chat's red and green icons, except with more > > variety. Basically, the problem I have now is that I want to include > > an imageview in the ListView's individual row xml fragment that will > > vary depending on the cursor information retrieved from the database. > > I'm having trouble doing this because the way the > > SimpleCursorAdapter's constructor is, I can only associate string > > types with TextViews. > > > Any help would be appreciated! Thank you > > > ps. this thread is something like what i'm looking for: > > >http://groups.google.com/group/android-developers/browse_thread/threa... > > > except mine is working with a database and a cursor > > > thank you! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] ListView with different images for each line
I'm creating a sort of "buddy list", using a ListView that draws information from a local sqlite database into a cursor and sets the ListView using a SimpleCursorAdapter. The Problem: I want to add icons for each entry in the buddy list, imagine something like Google Chat's red and green icons, except with more variety. Basically, the problem I have now is that I want to include an imageview in the ListView's individual row xml fragment that will vary depending on the cursor information retrieved from the database. I'm having trouble doing this because the way the SimpleCursorAdapter's constructor is, I can only associate string types with TextViews. Any help would be appreciated! Thank you ps. this thread is something like what i'm looking for: http://groups.google.com/group/android-developers/browse_thread/thread/5efe3b0bf6315c40/72870400f28d8179?lnk=gst&q=listview+image#72870400f28d8179 except mine is working with a database and a cursor thank you! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---