Hi, Alexander, Thank you. I have not describe the question clearly.
I want change the channel by pressing button. But press button once and the callback is called once. The channel only one channel up. But I want to change more channels. So I press the button and hold it. The callback will call a function change_channel(1). This function will increase the channel for every 0.2s. When user release the button the button state is changed again so the callback will kill the change_channel(0) and stop the channel change. I found OnFocusChangeListener did not work for pressing and hold of button. It only works when cursor moving by direction key. Shude On Fri, Oct 2, 2009 at 4:25 AM, Alexander Kazanin < alexander.kaza...@gmail.com> wrote: > > Hi. > > If I understood your intentions correctly you should set > OnLongClickListener. > Button button = (Button) findViewById(R.id.*channel_up*); > > button.setOnFocusChangeListener(new View.OnLongClickListener() > { > public boolean onLongClick(View view) > { > return false; > } > }); > > method onLongClick in this anonymous class will be called when user > presses and holds "cannnel_up" button for about 2 seconds > > On 2 окт, 03:08, Shude Zheng <sh...@excelfore.com> wrote: > > I want to add some code when user press and hold the button. I try use > > change the focus function. I wrote the similar code like onClick. But it > was > > never called when I moved curer to button and it was focused. > > > > Button button = (Button) findViewById(R.id.*channel_up*); > > > > button.setOnFocusChangeListener(*new* Button.OnFocusChangeListener() { > > > > *public* *void* onFocusChange(View v, *boolean* hasFocus) { > > > > } > > > > Thanks > > > > Shude > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---