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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:30:46+00:00 2026-05-15T17:30:46+00:00

I know this has been covered elsewhere, but I’m new to the Android platform

  • 0

I know this has been covered elsewhere, but I’m new to the Android platform and am having a hard time figuring out how to add basic menu options to my first app.

I have an options menu setup using

@Override
public boolean onCreateOptionsMenu(Menu menu){
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.menu, menu);
  return true;
}

and

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menuPrefs" android:icon="@android:drawable/ic_menu_preferences" android:title="Settings"></item>
</menu>

Then within my main java class I have

@Override
public boolean onOptionsItemSelected(MenuItem item){

 if(item.getItemId()==R.id.menuPrefs) {
  showPrefs();
 }
private void showPrefs() {
 Intent i = new Intent(this, Prefs.class);
 startActivity(i);
}

And then in Prefs.java I have

public class Prefs extends Activity {

     @Override
     protected void onCreate(Bundle savedInstanceState) {
      Toast.makeText(getBaseContext(), "FNORD", Toast.LENGTH_LONG).show();
     }
    }

Now from this I would expect to see the Toast message “FNORD” when the menu option is pressed, however the application stops unexpectedly.

If I move the toast statement into the showPrefs() function in place of the startActivity call it works.

  • 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-15T17:30:47+00:00Added an answer on May 15, 2026 at 5:30 pm

    You need to learn how to Debug in Eclipse and how to use the ADB and DDMS tools.

    In order to get more details about an exception/force close you need to look for a view in Eclipse called Logcat(you will find in the DDMS perspective) there you will find a detailed traceback when/what and on what line is the issue.

    For this you should read a complete article about Debugging in Android using Eclipse

    alt text
    (source: droidnova.com)

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

Sidebar

Related Questions

I know this has been discussed many times, but I am not sure I
I know this question has been asked before, but I ran into a problem.
I know this question has been asked a bit before. But looking around I
I know this specific question has been asked before , but I am not
I don't know if this has been discussed. Let's say you are in a
I know this questions has come up in various guises before, but this is
I don't know if anyone has seen this issue before but I'm just stumped.
This question has been discussed in two blog posts ( http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/ , http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/ ),
Ok, I know someone here has tried this ninja-elite level of coding before. Essentially
I've just solved another *I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-*issue (sigh). Does anybody know a good way to verify

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.