Hi Andy,

Thanks for your kind reply. What we are trying to do is just to
customize the search dialog's UI to match with the entire look&feel we
have designed for our client, for example, apply some custom animation
on the search suggestion list. We knew that reflection is certainly
not the preferable way to go. It was just meant to be an experimental
workaround given the current accessibility to the source code and SDK.
Since you have already provided a way for us to customize a few things
such as the icon and the text via metadata, it would probably make
sense for the SDK to go a bit further.  We will be very grateful if
you guys can provide us with some other suggestions.

Best,
Marty

On 2月13日, 上午10时38分, Andrew Stadler <stad...@gmail.com> wrote:
> Hello Marty,
>
> Unfortunately, the search dialog was not designed to be extended in
> this way.  This was not meant to "protect" it so much as a consequence
> of the data-driven design of the Search system.
>
> If you can describe some of the changes you have in mind, perhaps we
> can assist with some good suggestions.
>
> *Please* don't try to hack into it via reflection.  We cannot
> guarantee compatibility across multiple phone software versions.
>
> Andy Stadler (Google)
>
> On Mon, Feb 9, 2009 at 7:07 PM, Marty Wang <mo.hy.w...@gmail.com> wrote:
>
> > Hi Android folks,
>
> > We currently want to customize the default Android search dialog UI to
> > have our own look&feel. After looking into Android source code, we
> > found out that two things of Android preventing us from doing it.
>
> > 1. SearchManager declares an instance of SearchDialog as one of its
> > private fields
> > 2. SearchDialog is not compiled into the SDK. We are using 1.0R2.
>
> > As for problem 1, we actually could work it around by reflection. The
> > following is our code snippet to expose the private search dialog
> > field of SearchManager
>
> >                                SearchManager searchManager =
> > (SearchManager)getSystemService(Context.SEARCH_SERVICE);
>
> >                                try
> >                                {
> >                                        Class<?> searchManagerClass =
> > searchManager.getClass();
> >                                        Field searchDialogField =
> > searchManagerClass.getDeclaredField("mSearchDialog");
> >                                        searchDialogField.setAccessible
> > (true);
> >                                        searchDialogField.set
> > (searchManager, new OurCustomSearchDialog(context));
> >                                } catch (SecurityException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                } catch (NoSuchFieldException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                } catch (IllegalArgumentException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                } catch (IllegalAccessException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                }
> > However, when the code comes to the line
>
> > searchDialogField.set(searchManager, new OurCustomSearchDialog
> > (context));,
>
> > it brings up the second problem. Because SearchDialog is not in the
> > SDK, we have no way to create our custom search dialog by subclassing
> > it. Then the line is actually not possible.
>
> > Since the approach above cannot achieve our goal, I wonder if any of
> > you guys happen to know how to customize the default Android search
> > dialog, or at least why Google takes measures like that to protect
> > SearchDialog from being customized. Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to