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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:51:09+00:00 2026-06-15T17:51:09+00:00

I want to hit the pause button, then return to the previous class when

  • 0

I want to hit the pause button, then return to the previous class when buttons are clicked. I am having no trouble going to the Pause class, but then I cannot get back. Everything seems identical, so I think this may be a general hierarchy question or something like it, but I am not sure.

Pause class is called and runs correctly, but when I press the button, the program crashes. I am trying to return to the same class which I just left. I am using Eclipse. Thanks for your help! Here is my non-working code:

package com.evorlor.counter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

public class Pause extends Activity {

    @Override
    protected void onCreate(Bundle instPause) {

        super.onCreate(instPause);

        setContentView(R.layout.activity_counter);
        findViewById(R.id.textView1);
        TextView tv = (TextView) findViewById(R.id.textView1);

        tv.setGravity(Gravity.CENTER);
        tv.setTextSize(150);
        tv.setText("PAUSE");
    }

    public void resumeCounter(View view) {
        Intent resume = new Intent(Pause.this, Counter.class);
        startActivity(resume);
    }
}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Pause" >

    <TextView
        android:id="@+id/tvPause"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/btnResume"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:onClick="resumeCounter" />

</RelativeLayout>

12-12 01:02:27.796: E/AndroidRuntime(1883): FATAL EXCEPTION: main
12-12 01:02:27.796: E/AndroidRuntime(1883): java.lang.IllegalStateException: Could not find a method pauseCounter(View) in the activity class com.evorlor.counter.Pause for onClick handler on view class android.widget.Button with id 'button1'
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.view.View$1.onClick(View.java:3584)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.view.View.performClick(View.java:4202)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.view.View$PerformClick.run(View.java:17340)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.os.Handler.handleCallback(Handler.java:725)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.os.Looper.loop(Looper.java:137)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.app.ActivityThread.main(ActivityThread.java:5039)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at java.lang.reflect.Method.invokeNative(Native Method)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at java.lang.reflect.Method.invoke(Method.java:511)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at dalvik.system.NativeStart.main(Native Method)
12-12 01:02:27.796: E/AndroidRuntime(1883): Caused by: java.lang.NoSuchMethodException: pauseCounter [class android.view.View]
12-12 01:02:27.796: E/AndroidRuntime(1883):     at java.lang.Class.getConstructorOrMethod(Class.java:460)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at java.lang.Class.getMethod(Class.java:915)
12-12 01:02:27.796: E/AndroidRuntime(1883):     at android.view.View$1.onClick(View.java:3577)
12-12 01:02:27.796: E/AndroidRuntime(1883):     ... 11 more

Counter Class

package com.evorlor.counter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

public class Counter extends Activity {

    private int count = 0;
    private int hiCount = 0;
    private boolean capCount = false;

    @Override
    protected void onCreate(Bundle instCounter) {

        super.onCreate(instCounter);

        setContentView(R.layout.activity_counter);
        findViewById(R.id.textView1);
        TextView tv = (TextView) findViewById(R.id.textView1);

        tv.setTextSize(250);
        if (count < 10000 && capCount == false) {

            tv.setText(Integer.toString(count));
        } else {
            capCount = true;
            if (count >= 10000) {
                hiCount += 10;
                count -= 10000;
            }
            if (hiCount < 100) {

                tv.setText(hiCount + "k+" + count);
            } else {
                tv.setText("Over\n100k");
            }
        }
        tv.setGravity(Gravity.CENTER);

    }

    public void pauseCounter(View view) {
        Intent pause = new Intent(Counter.this, Pause.class);
        startActivity(pause);
    }

}

Counter layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Counter" >

    <TextView
        android:id="@+id/tvCounter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

    <Button
        android:id="@+id/btnPause"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:onClick="pauseCounter" />

</RelativeLayout>
  • 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-15T17:51:10+00:00Added an answer on June 15, 2026 at 5:51 pm

    You are using the same id for both buttons. Change one of the ids. Name it button2 for example. Same with your TextViews, but they aren’t referencing methods.

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

Sidebar

Related Questions

I want my user to be able to hit the submit button and have
When my users click the login button I want to hit my webservice. I
Hi I want to hit one URL that show an image in half page
i want to reduce the number of times i hit the data base to
I want to display sum of a column in a textbox when I hit
today i hit a really annoing problem with wpf. i just want to align
I'm trying to figure out Elisp, and I've hit a roadblock. I want a
I want to hit every page on my internal website to see if any
I don't want to hit the server and bring back every row when I
From Monday to Friday, 9 am to 4 pm I want to hit a

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.