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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:43:35+00:00 2026-06-14T04:43:35+00:00

Sorry to just dump code, but I’m trying to make a menu. When you

  • 0

Sorry to just dump code, but I’m trying to make a menu. When you start the program, It just says “Unfortunately, ScoutingDraft had stopped working.” I can’t figure out the problem.

package cody.graham.scoutingdraft;

import...;

public class MyMenu extends ListActivity{
    String UserName="a";
    String display[] = {"Welcome" ,"Login"  ,"Exit"    };
    String classes[] = {"return()","login()","finish()"};
    EditText user=(EditText) findViewById(R.id.ETUserInput);
    Button login=(Button) findViewById(R.id.BLogin),logout=(Button) findViewById(R.id.BLogout);
    TextView errmsg=(TextView) findViewById(R.id.TVErrorReport);
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(MyMenu.this,android.R.layout.simple_list_item_1,display));
    }
    @Override public void onBackPressed(){finish();}
    @Override
    protected void onListItemClick(ListView l, View v, int position,long id)
    {
        super.onListItemClick(l, v, position, id);
        if (classes[position].equals("return()")){return;}
        if (classes[position].equals("finish()")){finish();return;}
        if (classes[position].equals("login()")){
            final Dialog logd=new Dialog(this);
            logd.setContentView(R.layout.login_dialog);
            logd.setCancelable(false);
            login.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    int len=user.getText().toString().length();
                    if (len<3){errmsg.setText("Too short"); return;}
                    if (len>10){errmsg.setText("Too long"); return;}
                    UserName=user.getText().toString();
                    display[1]="Welcome, "+UserName;
                    display[2]="Logout";
                    logd.dismiss();
                }
            });
            logout.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    UserName="a";
                    display[1]="Welcome";
                    display[2]="Login";
                    logd.dismiss();
                }
            });
            logd.show();
            return;
        }
        try{
            Class<?> cvar=Class.forName("cody.graham.scoutingdraft."+classes[position]);
            Intent intention=new Intent(MyMenu.this,cvar);
            startActivity(intention);
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }
    }
    public String getUser(){
        return UserName;
    }
    public void setUser(String newuser){
        UserName=newuser;
    }
}

I don’t have any other java files yet(This is the whole program so far) but the only options I give it should trigger one of the 3 if statements and return before trying to create the class. Even if this weren’t true, it shouldn’t crash until I click something.

LogCat:

11-12 17:24:45.925: I/ActivityManager(165): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=cody.graham.scoutingdraft/.MyMenu bnds=[0,405][120,555] u=0} from pid 263
11-12 17:24:45.956: W/WindowManager(165): Failure taking screenshot for (246x410) to layer 21005
11-12 17:24:45.975: E/PowerManagerService(165): Excessive delay setting brightness: 140ms, mask=2
11-12 17:24:46.137: D/dalvikvm(6708): Not late-enabling CheckJNI (already on)
11-12 17:24:46.155: I/ActivityManager(165): Start proc cody.graham.scoutingdraft for activity cody.graham.scoutingdraft/.MyMenu: pid=6708 uid=10047 gids={1028}
11-12 17:24:46.235: E/PowerManagerService(165): Excessive delay setting brightness: 259ms, mask=2
11-12 17:24:46.525: E/PowerManagerService(165): Excessive delay setting brightness: 266ms, mask=2
11-12 17:24:46.606: I/Choreographer(165): Skipped 31 frames!  The application may be doing too much work on its main thread.
11-12 17:24:46.708: E/PowerManagerService(165): Excessive delay setting brightness: 176ms, mask=2
11-12 17:24:47.005: E/PowerManagerService(165): Excessive delay setting brightness: 284ms, mask=2
11-12 17:24:47.146: E/Trace(6708): error opening trace file: No such file or directory (2)
11-12 17:24:47.656: D/AndroidRuntime(6708): Shutting down VM
11-12 17:24:47.656: W/dalvikvm(6708): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-12 17:24:47.686: E/AndroidRuntime(6708): FATAL EXCEPTION: main
11-12 17:24:47.686: E/AndroidRuntime(6708): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cody.graham.scoutingdraft/cody.graham.scoutingdraft.MyMenu}: java.lang.NullPointerException
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.os.Looper.loop(Looper.java:137)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at java.lang.reflect.Method.invokeNative(Native Method)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at java.lang.reflect.Method.invoke(Method.java:511)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at dalvik.system.NativeStart.main(Native Method)
11-12 17:24:47.686: E/AndroidRuntime(6708): Caused by: java.lang.NullPointerException
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.Activity.findViewById(Activity.java:1825)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at cody.graham.scoutingdraft.MyMenu.<init>(MyMenu.java:18)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at java.lang.Class.newInstanceImpl(Native Method)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at java.lang.Class.newInstance(Class.java:1319)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
11-12 17:24:47.686: E/AndroidRuntime(6708):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
11-12 17:24:47.686: E/AndroidRuntime(6708):     ... 11 more
11-12 17:24:47.716: W/ActivityManager(165):   Force finishing activity cody.graham.scoutingdraft/.MyMenu
11-12 17:24:47.726: W/WindowManager(165): Failure taking screenshot for (246x410) to layer 21010
11-12 17:24:48.266: W/ActivityManager(165): Activity pause timeout for ActivityRecord{41980720 cody.graham.scoutingdraft/.MyMenu}
  • 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-14T04:43:37+00:00Added an answer on June 14, 2026 at 4:43 am

    It turns out I needed to remove

        EditText user=(EditText) findViewById(R.id.ETUserInput);
        Button login=(Button) findViewById(R.id.BLogin),logout=(Button) findViewById(R.id.BLogout);
        TextView errmsg=(TextView) findViewById(R.id.TVErrorReport);
    

    from the top, change them all to final variables, and move then all within the if statement:

            if (classes[position].equals("login()")){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi Sorry for posting a big dump of code but I'm very new at
Sorry if its just me who is scratching the head looking at this code,
sorry for the stupid questions but there are just some things about WCF I
Sorry if this is dumb but I was just thinking I should give a
Sorry for my inpatience but after weeks staying up late and just having put
Sorry, this might be a basic/stupid/noob question - I am just trying to tweak
Very sorry to be asking one of these questions, but I have been trying
Sorry guys,just a simple question but I cannot find exact question on google. The
Sorry if this is an elementary question but I've just started to consider whether
Sorry if this seems like a dumb question but I am just learning bash

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.