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

  • SEARCH
  • Home
  • 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 9224919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:26:54+00:00 2026-06-18T04:26:54+00:00

The startButton has an onTouchListener that, when pressed, starts a media player ( mp

  • 0

The startButton has an onTouchListener that, when pressed, starts a media player (mp in my source) and makes the same button have a stop function to it.

For example:
The user hits the start button and the music plays. Then the user hits the same button (which now has a setText of “Stop”) to stop the music player.

Is it possible to has multiple onTouchListener(s) within a method?

startButton.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {

                mp.start();
                timeLeft.setText("Status: Initiated");
                startButton.setText("Stop Dreaming");

                startButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        mp.stop();

                    }

                });

This is what I currently have… How would I set this up correctly?

  • 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-18T04:26:55+00:00Added an answer on June 18, 2026 at 4:26 am

    I suggest you use a toggle button for this endeavor:

    public void onToggleClicked(View view) {
        // Is the toggle on?
        boolean on = ((ToggleButton) view).isChecked();
    
        if (on) {
            mp.start();
                timeLeft.setText("Status: Initiated");
                startButton.setText("Stop Dreaming");
        } else {
            mp.stop();
        }
    }
    

    More info on toggle buttons here: http://developer.android.com/guide/topics/ui/controls/togglebutton.html

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

Sidebar

Related Questions

I have a launching Activity A1 which has a start button which starts a
I have a Gui for a stopwatch, it has a Start button, a Stop
I have a vb.net 2.0 program, that has a batch/queue routine to execute tasks
I'm creating an app that has start button which brings you to start page
I have a .NET 4 web application that has 3 separate projects associated –
I have a buttonlistener that removes the TextFields and the StartButton when it is
I have a HTML page which has four buttons Start, Stop, Pause and Resume
I have an android app where user presses a start button and some function
I'm creating a .jar file that has a GUI: jar cmf mainClass patcherFull.jar pack
It's encouraging that Shoes (the Ruby GUI framework) has excellent packaging functionality, but I'm

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.