0

i'm passing a rootView to setContentView:

root = (FlyOutMenu) this.getLayoutInflater().inflate(R.layout.activity_myLayout, null); setContentView(root); 

and the layout is defined like :

<com.android.xyz.view.viewgroup.FlyOutMenu.FlyOutMenu xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout android:id="@+id/RelativeLayoutMain" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/dialog_label_topic" /> <EditText android:id="@+id/dialog_searchbar_topic" android:ems="10" > </EditText> <Button android:id="@+id/dialog_menu_topic" /> <GridView android:id="@+id/gv1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/dialog_searchbar_topic" android:layout_alignParentBottom="true" > </GridView> </RelativeLayout> 

As you can see, it's a code in a different package in the same application.

I have two packages in my application:

1) com.android.xyz.view.viewgroup.FlyOutMenu 2) con.android.xyz

in my second package in the MainActivity i Override the onKeyDown- method but it never gets invoked.

@Override public boolean onKeyUp(int keyCode, KeyEvent event) { // TODO Auto-generated method stub Log.e("onKeyUp","Fired"); if(keyCode == KeyEvent.KEYCODE_BACK) { Log.e("fired with KeyEvent","true"); RelativeLayout.LayoutParams myLayoutParams = (android.widget.RelativeLayout.LayoutParams) gv.getLayoutParams(); myLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); gv.setLayoutParams(myLayoutParams); } return super.onKeyUp(keyCode, event); } 

I haven't attached any onFocus listener. The only View which requests Focus is my searchbar in my activity but it also doesn't have a Focus listener.

I tried following:

onKeyDown not always called in Android app

With no result... issue stays the same.

Any help is appreciated.

Does anybody know why this can't be invoked?

Thanks in advance

1 Answer 1

3

Hopefully this answer is not too late for your problem ;)

I ran into this same issue with my own custom view implementation and what I found out was that onKeyUp(int keyCode, KeyEvent event) is the keyboard handling event that is invoked on a View

However ViewGroup never invokes onKeyUp, instead it invokes its own method dispatchKeyEvent(KeyEvent event) and this is the one you need to @Override in your custom ViewGroup implementation.

Hope this helps out if someone else runs into this problem.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.