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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:16:38+00:00 2026-05-31T22:16:38+00:00

I have avery simple program which uses MediaPLayer. I am new to java and

  • 0

I have avery simple program which uses MediaPLayer. I am new to java and xml and for the life of me can’t figue out why the resume button I created won’t respond to a click event. It does sit on top of a larger imageButton, which should not repsond in this state, but I think the top level button should regardless, no?

package com.whynoceros.tonguechi;

 import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageButton;

public class ArtistsActivity extends Activity {

Button restart, resume, stop;
ImageButton play;
MediaPlayer audio;
boolean playing;
boolean paused;
boolean starting;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.tonguechi);
    audio = MediaPlayer.create(ArtistsActivity.this, R.raw.tongue_chi_mix1);

    playing = false;
    paused = false;
    starting = true;
    play = (ImageButton) findViewById(R.id.playbutton);
    stop = (Button) findViewById(R.id.stopbutton);
    resume = (Button) findViewById(R.id.resumebutton);
    restart = (Button) findViewById(R.id.restartbutton);



}
/*      play.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            audio.start();
            play.setBackgroundResource(R.drawable.pausebutton2x);
        }

    });
   */ 

public void playNow(View view) {
    if(paused){

    }

    if(playing){
        audio.pause();
        //play.setImageResource(R.drawable.playbutton2x);
        Animation slideA = AnimationUtils.loadAnimation(this, R.anim.stopani);
        stop.startAnimation(slideA);
        Animation slideB = AnimationUtils.loadAnimation(this, R.anim.resumeani);
        resume.startAnimation(slideB);
        Animation slideC = AnimationUtils.loadAnimation(this, R.anim.restartani);
        restart.startAnimation(slideC);
        playing=false;
        paused=true;
    }
    if(starting){
    audio.start();
    play.setImageResource(R.drawable.pausebutton2x);
    playing=true;
    starting=false;
    paused=false;
    Log.i("play","");


}
}

public void resumeNow(View v) {
    audio.start();
    Animation slideD = AnimationUtils.loadAnimation(this, R.anim.stopani);
    stop.startAnimation(slideD);
    Animation slideE = AnimationUtils.loadAnimation(this, R.anim.resumeani_rev);
    resume.startAnimation(slideE);
    Animation slideF = AnimationUtils.loadAnimation(this, R.anim.restartani_rev);
    restart.startAnimation(slideF);
    play.setEnabled(true);
    playing=true;
    paused=false;
    Log.i("resume","");

}

@Override
protected void onDestroy() {
    super.onDestroy();
    // TODO Auto-generated method stub
        audio.release();
    }

}





<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/playback2x"
android:orientation="vertical">

<ImageButton
    android:id="@+id/playbutton"
    android:layout_width="320dp"
    android:layout_height="131dp"
    android:layout_alignParentTop="true"
    android:layout_marginTop="34dp"
    android:scaleType="fitCenter"
    android:background="@android:color/transparent"
    android:src="@drawable/playbutton2x"
    android:contentDescription="button"
    android:onClick="playNow"/>

<Button
    android:id="@+id/resumebutton"
    android:layout_width="75dp"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="resume" android:layout_marginTop="-60dp"
    android:onClick="resumeNow"/>

<Button
    android:id="@+id/restartbutton"
    android:layout_width="75dp"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="restart" android:layout_marginTop="-60dp"/>

<Button
    android:id="@+id/stopbutton"
    android:layout_width="75dp"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="stop" android:layout_marginTop="-60dp"/>



<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/playbutton"
    android:layout_centerHorizontal="true"
    android:src="@drawable/tips2x" />


<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="280dp"
android:layout_height="240dp"
android:layout_alignTop="@+id/imageView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="53dp"
android:scrollbars="vertical"
android:fillViewport="true">
    <TextView
        android:id="@+id/editText1"
        android:layout_width="280dp"
        android:layout_height="240dp"
        android:layout_alignTop="@+id/imageView2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="53dp"
        android:inputType="textMultiLine"
        android:text="@string/tips_text"
        android:textColor="#6F372D"
        android:textSize="14dp"
        android:textStyle="normal"
        android:typeface="serif" />

  • 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-31T22:16:39+00:00Added an answer on May 31, 2026 at 10:16 pm

    I managed to solve my own problem using the following approach:

    I replaced all the xml animation with java TranslateAnimation.

    I created two separate xml layouts, one for the position of the buttons prior to animation, the other for after. In both layouts, I reference the same buttons, ids, etc…

    I created a setAnimationListener each time I begin an animation and then in the onAnimationEnd method, I apply the other xml layout. “setContentView(R.layout.layout2);” Also, immediately after setting the contentView, I had to re-instantiate the buttons, in order to get the click to work.

    Now, once the button stops moving, it’s actual location is updated to the final location of it’s appearance, vis-a-vis the animation.

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

Sidebar

Related Questions

I have developed a Java Swing application, which uses the SwingWorker class to perform
I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include
I have a very simple problem which requires a very quick and simple solution
I have a very simple WPF application in which I am using data binding
I have a very simple Java RMI Server that looks like the following: import
I have a very simple table and I can happily query it using LINQ
I have a program that uses the win32com library to control iTunes, but have
I have a very simple question. Look t my code which is written in
I have a very simple VB.net Windows Service written using VS.net 2008. The program
I have a very simple pure html file in which I have many PDF

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.