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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:22:12+00:00 2026-06-12T11:22:12+00:00

I have created two activities and added an onClick button to go to the

  • 0

I have created two activities and added an onClick button to go to the second activity from the first which works just fine …
But when i try to add a “back” button to the second activity to go back to the first activity
when i run it in the emulator when i click on back it says that the app has stopped working and the logcat is as follows

10-07 01:28:13.385: E/AndroidRuntime(628): FATAL EXCEPTION: main
10-07 01:28:13.385: E/AndroidRuntime(628): java.lang.IllegalStateException: Could not                         find a method back(View) in the activity class com.example.app2.MainActivity for onClick     handler on view class android.widget.Button
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.view.View$1.onClick(View.java:3578)
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.view.View.performClick(View.java:4084)
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.view.View$PerformClick.run(View.java:16966)
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.os.Handler.handleCallback(Handler.java:615)
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.os.Handler.dispatchMessage(Handler.java:92)
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.os.Looper.loop(Looper.java:137)
10-07 01:28:13.385: E/AndroidRuntime(628):  at android.app.ActivityThread.main(ActivityThread.java:4745)
10-07 01:28:13.385: E/AndroidRuntime(628):  at java.lang.reflect.Method.invokeNative(Native Method)

Heres a snippet from my code
the mainactivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}


    public void clubs(View v1) {
            setContentView(R.layout.activity_display_clubs);
    }

the clubsactivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

}


public void back(View v) {
    setContentView(R.layout.activity_main);


}
  • 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-12T11:22:13+00:00Added an answer on June 12, 2026 at 11:22 am

    this is not the correct way to start a new activity.

    you only change the views on the screen.

    to start a new activity:

    1. add the second activity tom manifist.xml file
    2. on clubs function (button click action) add this code

      Intent intent = new Intent(CurrentActivity.this, SecondActivity.class); startActivity(intent);

    and you dont need a back button on the second activity.
    android has a back button this not an iOS.

    you must read more about android development.

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

Sidebar

Related Questions

I have two activities; Home is my first activity and Settings is my second
I have an application which consists of two activities/screens and a java class from
Im making a multi activity application and the first two activities i made have
I have created two activities say A and B. Activity A lists list of
I have created two DbContexts, one is for application configuration, the second is for
I have an application which has two Activities, let's call them A and B.
I have two activities, one is main and I have another activity called Test
I have two activities, say Activity A and Activity B . Activity A is
I have two Activities. In my main Activity I am creating an intent to
I have two Activities and I want to keep a reference of a second

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.