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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:04:49+00:00 2026-05-31T20:04:49+00:00

So I have these five buttons that I want to be always present in

  • 0

So I have these five buttons that I want to be always present in all activities, sort of shortcut buttons to other activities. So i created a separate xml layout for this and just included them in the other activity layouts. I also created a class with corresponding methods that will handle the button clicks.

Now my problem is that I don’t know how to use/declare this class in my activities. When I try to run my app, logcat gives me an error that it couldn’t find the method handling the click.

How can I do that?

Here’s my buttons handler class:

package com.meralco.pms;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Toast;

public class ButtonsHandler extends Activity{

protected void startSin() {
    Intent launch = new Intent(this, SinActivity.class);
    startActivity(launch);
}
protected void startCity() {
    Intent launch = new Intent(this, CityActivity.class);
    startActivity(launch);
}

protected void startHelp() {
    Intent launch = new Intent(this, HelpActivity.class);
    startActivity(launch);

}
protected void startAll() {
    Intent launch = new Intent(this, AllActivity.class);
    startActivity(launch);

}
protected void startDate() {
    Intent launch = new Intent(this, DateActivity.class);
    startActivity(launch);

}
public void buttonClick(View v) {
    switch(v.getId())
      {
      case R.id.button_sin:
          Toast.makeText(v.getContext(), "SIN" , Toast.LENGTH_SHORT).show();
          startSin();
          break;
      case R.id.button_city:
          startCity();
          Toast.makeText(v.getContext(), "CITY" , Toast.LENGTH_SHORT).show();
          break;
      case R.id.button_date:
          startDate();
          Toast.makeText(v.getContext(), "DATE" , Toast.LENGTH_SHORT).show();
          break;
      case R.id.button_all:
          startAll();
          Toast.makeText(v.getContext(), "ALL" , Toast.LENGTH_SHORT).show();
          break;
      case R.id.button_help:
          startHelp();
          Toast.makeText(v.getContext(), "HELP" , Toast.LENGTH_SHORT).show();
          break;
      }
}
}

I think I am missing constructors. Am I heading the right way or I got it totally wrong? TIA!

  • 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-31T20:04:50+00:00Added an answer on May 31, 2026 at 8:04 pm

    I would change your ButtonsHandler to extend Fragment instead of Activity. Then you can include this fragment in all the rest of your activities. They will have to extend FragmentActivity in order to host your ButtonsHandler fragment and the layout files will reference com.meralco.pms.ButtonsHandler as a fragment.

    In order to support fragments in Android versions before 3.0, you’ll want to use the Android Compatibility Library: http://developer.android.com/sdk/compatibility-library.html

    You’ll also want to read up about Fragments: http://developer.android.com/guide/topics/fundamentals/fragments.html

    They are the recommended way for Android applications to re-use UI components like in this case:

    A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a “sub activity” that you can reuse in different activities).

    With regards to your buttons, you’ll want to hook up listeners like so:

    Button helpButton = (Button) findViewById(R.id.button_help);
    helpButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startHelp();
            Toast.makeText(v.getContext(), "HELP" , Toast.LENGTH_SHORT).show();                   
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp:wizard control that contains five WizardSteps. All of these steps have
I have grid view which contains five radio buttons per row. Out of these
Okay, what I currently have is a TabBarController with five tabs. Each of these
I have five fields for number input, and each of these fields must be
I have an unusual need. I have five input checkboxes that look like this:
I have a Silverlight 4 app that has a canvas with five MDIWindows on
I have five buttons in my current GUI named Browse, Unzip, Convert, Copy and
I have an application that presents a sort of catalog of items in a
Right now I have a site that I only allow about five people to
Hi, I have created the MultiChoice AlertDialog The AlertDialog has five list items with

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.