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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:48:50+00:00 2026-06-14T23:48:50+00:00

I am trying to add multiple button handlers for my app. I have successfully

  • 0

I am trying to add multiple button handlers for my app. I have successfully created one button that links to a web page. I am running into trouble with my next button, however. I want to go to a new screen on click. I have create the new screen xml file and the corresponding java file. I have also added the activity to the manifest. I’m just not sure how to add multiple button handlers to the main java page. I have attached how I did my first button. Any advice on how to add a second handler to this page for a button that will change view?

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    addListenerOnButton();

}

public void addListenerOnButton() {

    Button button = (Button) findViewById(R.id.button1);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

          Intent browserIntent = 
            new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.noblenet.org/eg/opac/home?locg=1"));
            startActivity(browserIntent);

        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
  • 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-14T23:48:51+00:00Added an answer on June 14, 2026 at 11:48 pm

    If I understand it correctly then buttons appear through onCreateOptionsMenu logic.
    Best way to handle the click events in this case would be to override onOptionsItemSelected API. Look here for more details

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

Sidebar

Related Questions

I have multiple forms on a page. I have created a button to hide
I am trying to add multiple markers each with its own infowindow that comes
Ok, I am trying to add one row of multiple images to a JPanel,
I have a loop where i am created multiple button instances and with each
I have a UINavigationController . I'm trying to add multiple buttons on the right
I am trying to add multiple different versions of the same button to the
I have multiple forms on a page where each form will add individual item
I am trying to add multiple google markers on a map and I am
I am trying to add multiple images to Html5 canvas but every time I
I'm trying to add multiple elements in a single row within a div. However,

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.