Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:17:09+00:00 2026-05-27T08:17:09+00:00

(Please note that the behavior described in this question only appeared because of something

  • 0

(Please note that the behavior described in this question only appeared because of something else seemingly unrelated we were doing. See the accepted answer.)

We have an Android activity with a GridView and a SlidingDrawer inside of a RelativeLayout. The way this activity responds to the trackball (or cursor keys) is rather odd. The focus will move among the items in the GridView, but whenever the cursor moves in a direction “out” of the GridView. (e.g. up when at the top, left when already at the leftmost item) the sliding drawer opens or shut. Notably, the focus stays on the same item in the GridView—it does not move to the sliding drawer.

With a trackball this is particularly horrible, as spinning the trackball past your real destination will cause the sliding drawer to repeatedly open and close.

We’ve determined that we can turn off the trackball entirely by overriding onTrackballEvent(). We’d prefer to have the trackball and cursor work normally on the GridView but not cause the sliding drawer to open or close. In principle we’d also like the trackball to focus on the various contents of the sliding drawer when it is open.

How?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:17:10+00:00Added an answer on May 27, 2026 at 8:17 am

    As it turned out, we caused this problem by an unrelated bit of foolishness. We wanted the MENU key to open and close the SlidingDrawer. We did this by overriding onPrepareOptionsMenu():

    public boolean onPrepareOptionsMenu (Menu menu) {
        slidingDrawer.animateToggle();
        return true;
    }
    

    This works fine; but it turns out it can be called when the menu is not about to be opened. In particular, if the Activity uses setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT), then an unhandled key event will end up accessing the menu. This includes trackball motion off the edge of the screen.

    The less dumb way to get the desired behavior is

    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if(keyCode==KeyEvent.KEYCODE_MENU) {
            slidingDrawer.animateToggle();
        }
        return super.onKeyUp(keyCode,event);
    }
    

    Meanwhile, we can get the trackball to move within the SlidingDrawer when it is open by setting up a SlidingDrawer.OnDrawerOpenListener which calls

    slidingDrawer.getContent().requestFocus();
    

    Finally it seems like a good idea to call

    slidingDrawer.getHandle().setFocusable(false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please note that this question is from 2008 and now is of only historic
[Please note that this is a different question from the already answered How to
(Please note that I have seen a similar question on StackOverflow recently, however I
Please note that this is not homework and i did search before starting this
Please note that I did ask this on Super User and received absolutely no
Please note: This is a question about the Eclipse plugin Subversive , and not
Note: This might seem like a Super User question at first, but please read
Please note that I already know of and understand the ABA problem . This
I mean things like: FK1 -> 1FK2 -> 2PK Please, note that 1FK2 is
Please note that there is no limitation of memory. I need to insert int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.