[android-developers] Re: disable the search key android alertdialog

2010-12-21 Thread dasorin2000
As Mark said, the solution is add your onKey inside the dialog.
Or create a custom dialog instead using Dialog. See below:

public class CustomDialog extends Dialog
{

public CustomDialog(Context context) {
super(context);
setOnKeyListener(new MyOnKeyListener());
}

class MyOnKeyListener implements
android.content.DialogInterface.OnKeyListener
{
@Override
public boolean onKey(DialogInterface dialog, int keyCode,
KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH)
{
System.out.println("- ignore search 
pressed");
return true;
}
return false;
}

}


}

-- 
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] Re: disable the search key android alertdialog

2010-12-13 Thread varun tewari
Try using 
onSearchRequested
().

Varun

On Sat, Dec 11, 2010 at 11:30 PM, Mark Murphy wrote:

> Put that in your Dialog subclass, then.
>
> On Sat, Dec 11, 2010 at 12:57 PM, acr  wrote:
> > To add to my original post.. I do have the following (which DOES
> > prevent the search key from being pressed) in the activity it just
> > doesn't work when the dialog is open.
> >
> > 
> > if (keyCode == KeyEvent.KEYCODE_SEARCH) {
> >System.out.println("search pressed");
> >return true;
> >}
> >
> >
> >
> >
> > On Dec 11, 12:49 pm, acr  wrote:
> >> Hi,
> >> Anyone know of a way to prevent the search key from canceling an alert
> >> dialog? I have alert.setCancelable(false); and it works fine for the
> >> back button, but when i hit the search key it goes to search.. and
> >> when I close the search my NON-Cancelable dialog is gone. any way to
> >> fix this. Please help
> >
> > --
> > 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
> >
>
>
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training in London: http://bit.ly/smand1 and http://bit.ly/smand2
>
> --
> 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] Re: disable the search key android alertdialog

2010-12-11 Thread Mark Murphy
Put that in your Dialog subclass, then.

On Sat, Dec 11, 2010 at 12:57 PM, acr  wrote:
> To add to my original post.. I do have the following (which DOES
> prevent the search key from being pressed) in the activity it just
> doesn't work when the dialog is open.
>
> 
> if (keyCode == KeyEvent.KEYCODE_SEARCH) {
>                        System.out.println("search pressed");
>            return true;
>        }
>        
>
>
>
> On Dec 11, 12:49 pm, acr  wrote:
>> Hi,
>> Anyone know of a way to prevent the search key from canceling an alert
>> dialog? I have alert.setCancelable(false); and it works fine for the
>> back button, but when i hit the search key it goes to search.. and
>> when I close the search my NON-Cancelable dialog is gone. any way to
>> fix this. Please help
>
> --
> 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
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in London: http://bit.ly/smand1 and http://bit.ly/smand2

-- 
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: disable the search key android alertdialog

2010-12-11 Thread acr
To add to my original post.. I do have the following (which DOES
prevent the search key from being pressed) in the activity it just
doesn't work when the dialog is open.


if (keyCode == KeyEvent.KEYCODE_SEARCH) {
System.out.println("search pressed");
return true;
}




On Dec 11, 12:49 pm, acr  wrote:
> Hi,
> Anyone know of a way to prevent the search key from canceling an alert
> dialog? I have alert.setCancelable(false); and it works fine for the
> back button, but when i hit the search key it goes to search.. and
> when I close the search my NON-Cancelable dialog is gone. any way to
> fix this. Please help

-- 
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