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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:30:48+00:00 2026-06-10T03:30:48+00:00

Currently i applied a DatePicker into my application and when i click the Button

  • 0

Currently i applied a DatePicker into my application and when i click the Button, it crashed. Below is the logcat:

08-18 00:22:39.564: E/AndroidRuntime(793): FATAL EXCEPTION: main
08-18 00:22:39.564: E/AndroidRuntime(793): java.lang.RuntimeException: Unable to start activity  ComponentInfo{com.stts.sparetimetradingsystem/com.stts.sparetimetradingsystem.employer.EditEventActivity}:  java.lang.NullPointerException
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.os.Looper.loop(Looper.java:123)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-18 00:22:39.564: E/AndroidRuntime(793):  at java.lang.reflect.Method.invokeNative(Native Method)
08-18 00:22:39.564: E/AndroidRuntime(793):  at java.lang.reflect.Method.invoke(Method.java:521)
08-18 00:22:39.564: E/AndroidRuntime(793):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-18 00:22:39.564: E/AndroidRuntime(793):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-18 00:22:39.564: E/AndroidRuntime(793):  at dalvik.system.NativeStart.main(Native Method)
08-18 00:22:39.564: E/AndroidRuntime(793): Caused by: java.lang.NullPointerException
08-18 00:22:39.564: E/AndroidRuntime(793):  at com.stts.sparetimetradingsystem.employer.EditEventActivity.updateDisplayFrom(EditEventActivity.java:532)
08-18 00:22:39.564: E/AndroidRuntime(793):  at com.stts.sparetimetradingsystem.employer.EditEventActivity.onCreate(EditEventActivity.java:236)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-18 00:22:39.564: E/AndroidRuntime(793):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-18 00:22:39.564: E/AndroidRuntime(793):  ... 11 more

Sorry for not placing my code. Here is my code:

private int mYear;
private int mMonth;
private int mDay;
static final int DATE_DIALOG_ID = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_event);

    edit_eventSpinner = (Spinner) findViewById(R.id.edit_spinner);
    btnSaveEvent = (Button) findViewById(R.id.btnSaveEvent);
    btnDeleteEvent = (Button) findViewById(R.id.btnDeleteEvent);
    edit_error = (TextView) findViewById(R.id.edit_error);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.salary_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    edit_eventSpinner.setAdapter(adapter);
    edit_eventSpinner
            .setOnItemSelectedListener(new OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> parent,
                        View view, int position, long id) {

                    if (position == 0) {
                        rate = "/hour";
                    } else if (position == 1) {
                        rate = "/day";
                    } else {
                        rate = "/month";
                    }
                }

                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

    // getting event details from intent
    Intent i = getIntent();

    // getting event id (EID) from intent
    eid = i.getStringExtra(TAG_EID);

    // Getting complete event details in background thread
    new GetEventDetails().execute();

    // save button click event
    btnSaveEvent.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            // starting background task to update event
            String e = edit_eventName.getText().toString();
            String c = edit_eventCName.getText().toString();
            String s = edit_eventSalary.getText().toString();
            String f = edit_eventFrom.getText().toString();
            String t = edit_eventTo.getText().toString();
            String whf = edit_eventWHFrom.getText().toString();
            String wht = edit_eventWHTo.getText().toString();
    });

    // Delete button click event
    btnDeleteEvent.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            // deleting event in background thread
            new DeleteEvent().execute();
        }
    });

    Button edit_pickDateFrom = (Button) findViewById(R.id.edit_pickDateFrom);

    edit_pickDateFrom.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
        }
    });

    updateDisplayFrom();
}

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {

    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, mDateSetListenerFrom, mYear,
                mMonth, mDay);
    }
    return null;
}

protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {

    case DATE_DIALOG_ID:
        ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
        break;
    }

}

// SET THE DATE FORMAT ALREADY USER SELECT FROM THE DATEPICKER
private void updateDisplayFrom() {
    edit_eventFrom.setText(new StringBuilder()
            // Month is 0 based so add 1
            .append(mDay).append("-").append(mMonth + 1).append("-")
            .append(mYear).append(""));
}

private DatePickerDialog.OnDateSetListener mDateSetListenerFrom = new DatePickerDialog.OnDateSetListener() {

    public void onDateSet(DatePicker view, int year, int monthOfYear,
            int dayOfMonth) {
        mYear = year;
        mMonth = monthOfYear;
        mDay = dayOfMonth;
        updateDisplayFrom();
    }
};

Below is the new error that i get after even though i initialized the edit_eventName etc.

08-18 01:09:56.764: E/AndroidRuntime(977): FATAL EXCEPTION: main
08-18 01:09:56.764: E/AndroidRuntime(977): java.lang.IllegalArgumentException: current should be >= start and <= end
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.widget.NumberPicker.setCurrent(NumberPicker.java:288)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.widget.DatePicker.updateDaySpinner(DatePicker.java:364)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.widget.DatePicker.updateSpinners(DatePicker.java:350)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.widget.DatePicker.init(DatePicker.java:346)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.DatePickerDialog.<init>(DatePickerDialog.java:124)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.DatePickerDialog.<init>(DatePickerDialog.java:83)
08-18 01:09:56.764: E/AndroidRuntime(977):  at com.stts.sparetimetradingsystem.employer.EditEventActivity.onCreateDialog(EditEventActivity.java:527)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.Activity.onCreateDialog(Activity.java:2472)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.Activity.createDialog(Activity.java:881)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.Activity.showDialog(Activity.java:2547)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.Activity.showDialog(Activity.java:2514)
08-18 01:09:56.764: E/AndroidRuntime(977):  at com.stts.sparetimetradingsystem.employer.EditEventActivity$5.onClick(EditEventActivity.java:245)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.view.View.performClick(View.java:2408)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.view.View$PerformClick.run(View.java:8816)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.os.Handler.handleCallback(Handler.java:587)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.os.Looper.loop(Looper.java:123)
08-18 01:09:56.764: E/AndroidRuntime(977):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-18 01:09:56.764: E/AndroidRuntime(977):  at java.lang.reflect.Method.invokeNative(Native Method)
08-18 01:09:56.764: E/AndroidRuntime(977):  at java.lang.reflect.Method.invoke(Method.java:521)
08-18 01:09:56.764: E/AndroidRuntime(977):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-18 01:09:56.764: E/AndroidRuntime(977):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-18 01:09:56.764: E/AndroidRuntime(977):  at dalvik.system.NativeStart.main(Native Method)
  • 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-10T03:30:49+00:00Added an answer on June 10, 2026 at 3:30 am

    It seems as though you have not initialized edit_eventFrom anywhere in the code you posted.

    You will need to inflate that View from your layout, like you did your other Views:

    edit_eventSpinner = (Spinner) findViewById(R.id.edit_spinner);
    btnSaveEvent = (Button) findViewById(R.id.btnSaveEvent);
    btnDeleteEvent = (Button) findViewById(R.id.btnDeleteEvent);
    edit_error = (TextView) findViewById(R.id.edit_error);
    

    And as swayam mentioned, you will need to do this for any View you are wanting to use in your code.

    swayam

    Similarly, initialize all the following EditText views before using in your code


    Second Error

    IllegalArgumentException: current should be >= start and <= end

    You need to initialize mYear, mDay and mMonth to some default or whatever value you want.

    Reference for this solution.

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

Sidebar

Related Questions

Currently, I am writing a MiddleWare application that synchronizes information between and accounting application
Currently working with converting SQLException error messages into messages that are more useful for
currently im drawing a background, then a transparent triangle into the stencil buffer, then
I currently have data that I am splitting into multiple sheets and allowing the
Currently i am using Telerik grid which filters are applied to each column. I
I've currently created a partition scheme / function in my database, and applied it
I am currently working on two web sites. http://www.campusreader.org/#About if you click on someones
I'm currently working on a MVC.NET 3 application; I recently attended a course by
I am looking to remover the circle bullet list style that is currently applied
I am currently trying to make a navigation-menu where an active-class is applied to

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.