1

I have an issue in my Android Tablet app (7 inch tablet) where I need to tap any View twice in order for the click event or focus event to fire. When I say any view I mean : (ImageView, EditText, Spinner or any Custom view (i.e: a RelativeLayout with child views )) . After having to initially tap twice-- the click event then seems more responsive. But then going to the next Activity the same issue arises. I have seen solutions where you use Touch Events instead or Listen for a focus event in addition to the click event then call performClick() but none of these have worked and just seems like Band Aides and are not getting to the root of the issue . I need an all encompassing solution here for all views in all my Activities. I'm on Android 4.2.2 using SDK 16. Also it doesn't matter if the event concerns a root layout or child View.

UPDATE (1-30-2015): I believe the issue has to do with the navigation bar or "soft buttons" . I hide this always by default to gain real estate. However, if I swipe up to reveal the navigation bar, then tap one of my view it will fire the click event reliably. So how can I hide the navigation bar AND have my click event fire reliably? Hmmmm.....

Sample view that does not receive a click event reliably:

<ImageView
            android:id="@+id/img_ts_logo"
            android:layout_width="@dimen/app_icon_width"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:layout_centerVertical="true"
            android:layout_marginLeft="@dimen/app_icon_margin"
            android:layout_marginRight="@dimen/app_icon_margin"
            android:src="@drawable/logo_notext"/>  




    private View.OnClickListener logoListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.setClassName("com.android.settings", "com.android.settings.LanguageSettings");
            startActivity(intent);
        }
    };
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Mike6679
  • 5,547
  • 19
  • 63
  • 108

1 Answers1

1

I think this has to do with the soft navigation bar showing up (I am assuming you hide it initially), perhaps if you permanently hide the navigation keys you won't have to double tap (the initial tap which brings up the hidden keys and then the listeners on the buttons activate)

Try this on your buttons or your main layout:

[view].setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Reference: Hide ICS back home task switcher buttons

Community
  • 1
  • 1
Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
  • 1
    Got some bad news for tablets: "The SYSTEM_UI_FLAG_HIDE_NAVIGATION is a new flag that requests the navigation bar hide completely. Be aware that this works only for the navigation bar used by some handsets (it does not hide the system bar on tablets). The navigation bar returns to view as soon as the system receives user input. As such, this mode is useful primarily for video playback or other cases in which the whole screen is needed but user input is not required." [http://developer.android.com/about/versions/android-4.0.html#SystemUI] – Quintin Balsdon Jan 30 '15 at 18:10