RE: [android-developers] Button State does not toggle automatically!! Help!
Hi, Try button.setEnabled(false); button.setEnabled(true); I hope that would help :) Marian -Original Message- From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of Abhi Sent: Monday, August 23, 2010 4:30 AM To: Android Developers Subject: [android-developers] Button State does not toggle automatically!! Help! Guys, I am trying to get the button in my layout to have focus as I am programmatically changing its state. My application is a video player using VideoView. I am toggling the state of the button based on where my video is. So basically, I am doing videoview.getCurrentPosition() and if it is in a certain window, I want to toggle my Button state (enabled to disabled and vice versa). The layout is LinearLayout and I have the VideoView and Button layed horizontally. When I first had the MediaController in my Video, the button would change focus on touching the videoview (which is when the MediaController would pop up). I later removed the controller because I didn't want the button state to change when the user touches the screen. I want it to change automatically. I tried all sorts of combinations possible. button.setFocusable(), button.requestFocus(), button.bringToFront() and so on. But none of them seem to work. Is there any way I can make it toggle programatically and without user intervention through touch? or is it impossible to do it with the VideoView? Thanks, Abhi -- 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 -- 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
Re: [android-developers] Button State does not toggle automatically!! Help!
Abhi, I am a little confused - you mentioned changing button state and then talk about focus. Enabled/disabled state is one thing, and focus is quite another. Try calling: button.setEnabled(true or false) Note that for an ImageButton you need to have a state drawable like this to select image depending on the button's state. // my_button_selector.xml ?xml version=1.0 encoding=utf-8? selector xmlns:android=http://schemas.android.com/apk/res/android; item android:state_enabled=false android:drawable=@drawable/my_button_disabled / item android:drawable=@drawable/my_button_normal / /selector my_button_disabled and my_button_normal are images (.png or .9.png) // in layout xml ImageButton . android:src=@drawable/my_button_selector 23.08.2010 5:30, Abhi пишет: Guys, I am trying to get the button in my layout to have focus as I am programmatically changing its state. My application is a video player using VideoView. I am toggling the state of the button based on where my video is. So basically, I am doing videoview.getCurrentPosition() and if it is in a certain window, I want to toggle my Button state (enabled to disabled and vice versa). The layout is LinearLayout and I have the VideoView and Button layed horizontally. When I first had the MediaController in my Video, the button would change focus on touching the videoview (which is when the MediaController would pop up). I later removed the controller because I didn't want the button state to change when the user touches the screen. I want it to change automatically. I tried all sorts of combinations possible. button.setFocusable(), button.requestFocus(), button.bringToFront() and so on. But none of them seem to work. Is there any way I can make it toggle programatically and without user intervention through touch? or is it impossible to do it with the VideoView? Thanks, Abhi -- Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com -- 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] Button State does not toggle automatically!! Help!
Guys, I am trying to get the button in my layout to have focus as I am programmatically changing its state. My application is a video player using VideoView. I am toggling the state of the button based on where my video is. So basically, I am doing videoview.getCurrentPosition() and if it is in a certain window, I want to toggle my Button state (enabled to disabled and vice versa). The layout is LinearLayout and I have the VideoView and Button layed horizontally. When I first had the MediaController in my Video, the button would change focus on touching the videoview (which is when the MediaController would pop up). I later removed the controller because I didn't want the button state to change when the user touches the screen. I want it to change automatically. I tried all sorts of combinations possible. button.setFocusable(), button.requestFocus(), button.bringToFront() and so on. But none of them seem to work. Is there any way I can make it toggle programatically and without user intervention through touch? or is it impossible to do it with the VideoView? Thanks, Abhi -- 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