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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:03:23+00:00 2026-06-07T05:03:23+00:00

I have been having trouble with setting an initial input on my EditTexts. Whenever

  • 0

I have been having trouble with setting an initial input on my EditTexts. Whenever I pass an intent containing a string from previous activity, it leads to a forced close.

The main gist of my program is that, a previous activity sends an intent containing a string to the editText activity. If it’s not initialized, editTexts are blank, else, they contain the values shown in the TextView from the previous screen. Here is my code:

EditText month, day, year;

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

    Intent startUp = getIntent();
    String receivedString = startUp.getStringExtra(Lab2_082588part2.BIRTHDAY_STRING);

    if(receivedString.trim().length() > 0){
        String[] separated = receivedString.split("/");

        int stringMonth = Integer.parseInt(separated[0]);
        int stringDay = Integer.parseInt(separated[1]);
        int stringYear = Integer.parseInt(separated[2]);

        month.setText(stringMonth);
        day.setText(stringDay);
        year.setText(stringDay);

    }
}

Here is my LogCat

07-06 15:05:19.918: E/AndroidRuntime(276): Caused by: java.lang.NullPointerException

07-06 15:05:19.918: E/AndroidRuntime(276):  at com.android.rondrich.Lab2_082588birthday.onCreate(Lab2_082588birthday.java:34)

07-06 15:05:19.918: E/AndroidRuntime(276):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

07-06 15:05:19.918: E/AndroidRuntime(276):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  • 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-07T05:03:25+00:00Added an answer on June 7, 2026 at 5:03 am

    First initialize textView’s after
    setContentView(R.layout.lab2_082588birthday); as:

    month = (TextView)findViewById(R.id.month);
     day = (TextView)findViewById(R.id.day);
     month = (TextView)findViewById(R.id.year);
    

    and then Set Integer Value to TextView as:

    month.setText(stringMonth+"");
    day.setText(stringDay+"");
    year.setText(stringDay+"");
    

    or

    month.setText(String.valueOf(stringMonth));
    day.setText(String.valueOf(stringDay));
    year.setText(String.valueOf(stringDay));
    

    as after provide logcat:
    check array lenth before paring String to int
    :

    if(separated.length >0)
    {
            int stringMonth = Integer.parseInt(separated[0]);
            int stringDay = Integer.parseInt(separated[1]);
            int stringYear = Integer.parseInt(separated[2]);
    
            month.setText(stringMonth+"");
            day.setText(stringDay+"");
            year.setText(stringDay+"");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having trouble setting a box shadow on the left side of
Hello I have been having trouble with this for a while now. I have
I am having trouble writing a query. I have been working with UNION on
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
No doubt elements of this question have been asked before, but I'm having trouble
I have been having some trouble finding a good way to output just the
I have been having a lot of trouble getting cocotron to create a simple
I'm having some trouble setting up Apache on Ubuntu. I've been following this guide
I have been having the following problem, i think it's probably due to the
We have been having some debate this week at my company as to how

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.