Hi,
Indeed the way you advised is quite easier ;)
As an help for next people:

searchBar = (EditText)findViewById(R.id.searchTextView);
//
searchBar.setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
    // code
}
});

Thanks
Polo


On Nov 6, 3:06 pm, hackbod <[EMAIL PROTECTED]> wrote:
> You need to implement the constructor used for inflating from XML --
> look at the View constructors for the appropriate one.
>
> Also generally this kind of thing is better done by attaching
> listeners (of which TextView offers a whole host) rather than
> subclassing.
>
> On Nov 6, 11:38 am, polo777 <[EMAIL PROTECTED]> wrote:
>
> > Hi Everyone,
>
> > I am trying desperately to extend the EditText view to override
> > onKeyDown. My goal is to create an EditText that will update UI
> > elements each time the user will type one character within.
>
> > The code is as simple as that:
>
> > public class SearchView extends EditText
> > {
> >         public SearchView(Context context)
> >         {
> >                 super(context);
> >         }
>
> >     [EMAIL PROTECTED]
> >      public boolean onKeyDown(int keyCode, KeyEvent event)
> >      {
> >          // the code (right now nothing)
> >          return true;
> >      }
>
> > }
>
> > The main package is "com.android.polo.myApp"
> > It is located in the package "com.android.polo.myApp.view"
>
> > Here is the "View.xml" using this new view:
>
> >     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >         android:orientation="horizontal"
> >         android:layout_width="fill_parent"
> >         android:layout_height="wrap_content">
>
> >         <com.android.polo.myApp.view.SearchView
> >                 android:id="@+id/searchTextView"
> >                 android:layout_width="fill_parent"
> >                 android:layout_height="wrap_content"/>
>
> >     </LinearLayout>
>
> > I got this error:
>
> > 11-06 19:00:21.555: ERROR/AndroidRuntime(1207):
> > java.lang.RuntimeException: Unable to start activity
> > ComponentInfo...... android.view.InflateException: Binary XML file
> > line #28: Error inflating class com.android.polo.myApp.view.SearchView
> > ....
> > 11-06 19:00:21.555: ERROR/AndroidRuntime(1207): Caused by:
> > android.view.InflateException: Binary XML file line #28: Error
> > inflating class com.android.polo.MyApp.view.SearchView
> > ......
> > 11-06 19:00:21.555: ERROR/AndroidRuntime(1207): Caused by:
> > java.lang.NoSuchMethodException: SearchView
>
> > Thanks a lot in advance
> > Polo
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to