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

  • Home
  • SEARCH
  • 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 416445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:28:52+00:00 2026-05-12T18:28:52+00:00

I would if anyone can help.. I am coming from a c# background so

  • 0

I would if anyone can help.. I am coming from a c# background so i have the syntax basics of java and i following the hello world tutorial which has 1 activity (inherits from Activity) which basically shows my view like so

     setContentView(R.layout.main);

So what i wanted to do (by viewing a tutorial) is create a menu by implementing (override) this method

     onCreateOptionsMenu

but my activity class inherits Activity and it seems that this is not available in the superclass..

I am a little confused, can i create more than 1 Activity class? hence should i create a Menus Activity class that inherits from a different superclass?

If this is the case how would i call the new activity class i have created from my

     public void onCreate

which is implemented on my main activity class that inherits Activity.

I am a little confused and i can’t seem to find any concrete info with regards to this.

Any ideas?

Here is my simple activity class (its basically shows the view)

public class DGAdmin extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //TextView tv = new TextView(this);
    //tv.setText("Hello, Android");
    //setContentView(tv);

}

}

  • 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-12T18:28:53+00:00Added an answer on May 12, 2026 at 6:28 pm

    For a menu, add (e.g.) the following method to your class DGAdmin:

    public static final int ITEM_1 = Menu.FIRST;
    public static final int ITEM_2 = Menu.FIRST + 1;
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
    
        // Add two example menu buttons
        int groupId = 0;
        int menuItemOrder = Menu.NONE;
    
        int menuItemId = ITEM_1;
        String menuItemText = "item 1";
        MenuItem menuItem = menu.add(groupId, menuItemId, menuItemOrder, menuItemText);
        menuItem.setIcon(R.drawable.menu_item_1_icon);
    
        menuItemId = ITEM_2;
        menuItemText = "item 2";
        menuItem = menu.add(groupId, menuItemId, menuItemOrder, menuItemText);
        menuItem.setIcon(R.drawable.menu_item_2_icon);
    }
    

    Regarding the question about creating and calling a new activity, I think you need to read a little more about the android fundamentals, e.g. the life-cycle of an activity, the different components (activities, services, xml-based layouts, etc) in order to get a better feeling of how to write your android apps. I’m pretty new to android myself, so I know that it can be quite frustrating before you get the hang of it all. But just keep on reading and writing code and all will come clear pretty soon.

    Read through the application fundamentals in the dev guide, check out the answers to this question (and this), and check the API reference for the methods or classes that are new to you.

    But to explicitly answer your question, you use an intent to start a new activity:

    Intent intent = new Intent(callingActivity.this, NewActivity.class);
    startActivity(intent);
    

    Or if you want the new activity to return some result when it has finished executing:

    startActivityForResult(intent, requestCode);
    

    Hope this can be of at least some help!


    UPDATE TO ANSWER COMMENT:

    Are you using the following imports in your code?

    import android.app.Activity;
    import android.view.Menu;
    import android.view.MenuItem;
    

    If you do and it still doesn’t work, I don’t know what the problem might be…

    Since Android 1.0, the Activity class includes the method onCreateOptionsMenu(), so it should be available to you. Are you using Eclipse as your development environment? If you don’t, I really recommend that you start using it with the android-plugin, it is really smooth! Check out how to install it in the answers to this question.

    I hope this solves your problem, otherwise maybe someone more experienced than me can tell you what the problem is.

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

Sidebar

Ask A Question

Stats

  • Questions 255k
  • Answers 255k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This answer to the linked question should work for you… May 13, 2026 at 10:18 am
  • Editorial Team
    Editorial Team added an answer You should be able to accomplish this easily with a… May 13, 2026 at 10:18 am
  • Editorial Team
    Editorial Team added an answer In both Latin-1 (ISO-8859-1) and Windows-1252, 0xc2 would a capital… May 13, 2026 at 10:18 am

Related Questions

Pre-warning : There are some other questions similar to this but don't quite answer
boolean a = false, b = true; if ( a && b ) {
I've been coding php for a while now and have a pretty firm grip
If i was to make a new program and wanted to have a fraction

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.