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 7895833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:44:19+00:00 2026-06-03T07:44:19+00:00

I have a layout called a controller in it i have a couple buttons

  • 0

I have a layout called a controller in it i have a couple buttons and such
the problem is in my onTouch function i want to show it on one click and hide it on another. Now this works after 2 touches. The first touch is supposed to show the controller while the next is supposed to make it disappear. The first and second touches do nothing but on the third touch it works. Here are the related functions for this

public boolean onTouchEvent(MotionEvent event)
{

    int eventx = event.getAction();
    switch(eventx)
    {
    case MotionEvent.ACTION_DOWN:
        if(isLifted)
        {
            if(!isVisible)
            {
                Log.i("onTouch", "called showPuse menu");
                isVisible = true;
                isPaused = true;
                showPauseMenu();
            }
            else if(isVisible)
            {
                hidePauseMenu();
                isVisible= false;
            }
            isLifted = false;

        }
        break;
    case MotionEvent.ACTION_UP:
        if(!isLifted)
        {
            isLifted = true;
            //Log.i("onTouchEvent", "Lifted");
        }
    }
    return false;
}

    /***************************************************
 * Shows All Views needed to be shown
 * Also pauses video and audio
 *
 * *************************************************/
private void showPauseMenu()
{
    Log.i("showPauseMenu", "called");
    playButton.setVisibility(View.VISIBLE);
    Log.i("showPauseMenu", "plaButton visible");
    bottomButtons.setVisibility(View.VISIBLE);
    Log.i("showPauseMenu", "bottom Menu showed");
    playButton.invalidate();
    bottomButtons.invalidate();
    pauseMedia();
}
/************************************************
 * Hides Views that are part of Pause Menu
 * Also starts video and audio back again
 */
private void hidePauseMenu() {
    playButton.setVisibility(View.GONE);
    bottomButtons.setVisibility(View.GONE);
    playMedia();
}

Can anyone say what the problem might be? I’ve been looking at this code for a couple of days now and cant see what it might be.

  • 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-06-03T07:44:21+00:00Added an answer on June 3, 2026 at 7:44 am

    A few pointers about this code:

    • The isLifted variable presumably starts out false, and on the first touch event it causes nothing to happen on the down event. When the user lifts his/her finger the variable is set to true so the second event can actually be processed. This means the first touch will never have any visible effect.
    • You’re using an isVisible boolean instead of just checking the visibility of the components themselves. This makes it very easy to get them out of sync.

    Without the full class it’s hard to tell, but I’d investigate both these points.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a layout that contains two ImageViews. I want one of them to
I have a boolean field called saved in my database. I want to toggle
I have this layout file called menuAdmin. I wish to, each time a given
I have created a file called myblock.phtml in frontend\default\default\layout\mytemplate .It simply displays a check
I have a couple of variables that need to be called in all controllers.
I have a @Html.Action() in my layout, and putting a breakpoint in the controller
I have a table called car_parts, and my controller is called CarPartsController, file is
I have a controller which has 3 functions. I wish to show 3 different
I have a namespace let's say called pro and I want to put my
I have an element for my side bar navigation being called from my layouts/default.ctp

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.