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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:56:26+00:00 2026-05-28T01:56:26+00:00

I am new to Android and I have multiple classes. I was wondering if

  • 0

I am new to Android and I have multiple classes.
I was wondering if there is a way that I could somehow include four classes in one major class.

Below is example of my code.
I am looking forward to help.

This is the FindUs class (major class)

package com.abc.example;

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

public class FindUs extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.findUs);

            Button first = (Button) findViewById(R.id.first);
            Button second = (Button) findViewById(R.id.second);
            Button third = (Button) findViewById(R.id.third);
            Button fourth = (Button) findViewById(R.id.fourth);

            first.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    startActivity(new Intent("com.abc.example.FIRST"));
                }
            });

            second.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    startActivity(new Intent("ccom.abc.example.SECOND"));
                }
            });

            third.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    startActivity(new Intent("com.abc.example.THIRD"));
                }
            });

            fourth.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    startActivity(new Intent("com.abc.example.FOURTH"));
                }
            });             
}

These are the minor classes (it makes sense only to post one).

package com.abc.example;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class First extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.first);

    Button callFirst= (Button) findViewById(R.id.callfirst);
    Button mapFirst= (Button) findViewById(R.id.mapfirst);

    callFirst.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String phoneNumber = "tel:+18000000000";
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse(phoneNumber));
            startActivity(callIntent);

        }
    });

    mapFirst.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String url = "grab google directions for this place";
            Intent mapIntent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));
            startActivity(mapIntent);
                }
            });             
}

So you see, I will have different numbers and location for each class. So I am unsure if I should just keep the four individual classes or if I should include all four within one major class.

Thanks. Looking forward to learning more about this from your guys.

  • 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-28T01:56:26+00:00Added an answer on May 28, 2026 at 1:56 am

    You should have every activity in a separate file.

    If you have helper classes that that are only used in one activity you can use an inner class or put it below the other one (not public). Activities should be separate files.

    What you could do is put code that has to be in the two classes also in a separate class so that both of them can use it.

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

Sidebar

Related Questions

i'm new at Android world, and i have a doubt, is there any method
I have to admit that I'm new to Java and Android. db4o seems to
i am quite new to android and i was wondering how i could go
I have a common library where I've put classes that are used between multiple
I am building an android application that reads text files. Now,i have multiple text
Hi I’m new to android and I’m developing a reminder that have three categories
i am new programmer in android application i would like display multiple notifications one
I am relatively new to Android development. My requirement is such that I have
Ok, im fairly new to android but i have managed to teach myself the
I am completely new to android, and pretty much a Java newb. I have

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.