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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:50:34+00:00 2026-05-28T04:50:34+00:00

I cant seem to link more than one button on a page. The page

  • 0

I cant seem to link more than one button on a page.
The page basically has a heading, and 3 buttons below that which link to 3 different topics
The code that i have tried (which i found on this site) was:

   package com.ICTrevisionapp;

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

    public class topicstoquiz extends Activity {
        /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.topics);}
        public void onClick(View v) {
        {
            Button clickedButton = (Button) v;
            setContentView(0);
            switch(clickedButton.getId())
            {
            case R.id.button2:
                    setContentView(R.layout.topic1);
                Intent myIntent = new Intent (v.getContext(),topicstotopicone.class);
                startActivityForResult(myIntent, 0);
                break;
            case R.id.button3:
                setContentView(R.layout.topic2);
                break;
            }
        }
    }

The case part.

I have also tried the code:

        Intent myIntent = new Intent (view.getContext(),topicstoquiz.class);
        startActivityForResult(myIntent, 0);

but I can only seem to get It to link to one activity and only from one button.

Im probably doing this completely wrong, so how would I link each button on the page, to a seperate activity so I can link them to other pages. (If that makes sense)

  • 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-28T04:50:34+00:00Added an answer on May 28, 2026 at 4:50 am

    I prefer to go “the long way” about this:

    In your onCreate:
    Button button2 = (Button)findViewById(R.id.button2);
    button2.setOnClickListener(yourListener);

    Then create the listener method:
    private OnClickListener yourListener = new OnClickListener(){
    public void onClick(View v){
    Intent yourIntent = new Intent(yourCurrentActivity.this, classYoureNavigatingToo.class);
    startActivity(yourIntent);
    }
    };

    So you can set up separate listeners for each button, pointing to a different class. If it helps don’t forget to mark as answer!

    Update:

    public class topicstoquiz extends Activity {
    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.topics);
    Button button2 = (Button)findViewById(R.id.button2);
    Button button3 = (Button)findViewById(R.id.button3);
    Button button4 = (Button)findViewById(R.id.button4);
    button2.setOnClickListener(button2Listener);
    button3.setOnClickListener(button3Listener);
    button4.setOnClickListener(button4Listener);
    }

    Set up your click listeners like I showed above. You are specifing your activity in your AndroidManifest.xml correct? Post stack trace result when you get the force close please.

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

Sidebar

Related Questions

I know there is more than one question out there that matches this, but
Cant seem to get the following to find the 'skull' button when the 'heart'
I cant seem to compare two JS files (one edited locally and the latest
I have a problem which I cant seem to find answer to through searches
I Have a display that needs to be a little more dynamic than what
I have a 2 ajax functions on my page. One that works when a
I cant seem to find much info on haskells layout features, as I understand
I cant seem to grasp the proper concepts of a factory. Can anyone help
I cant seem to find the PythonMagick (Bindings for ImageMagick) documentation anywhere. Even the
I cant seem to get VB to focus on a textbox correctly at the

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.