I was able to figure out everything out after a few hours of
tinkering. Part of the problem was an error in the code they supply
for the OnDateSetListener callback. You need to use "@Override" before
you override any method, but for whatever reason they left it out when
they override their onDateSet method. So it should look like this:

    // the callback received when the user "sets" the date in the
dialog
    private DatePickerDialog.OnDateSetListener mDateSetListener =
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year,
                                      int monthOfYear, int dayOfMonth)
{
                    mYear = year;
                    mMonth = monthOfYear;
                    mDay = dayOfMonth;
                    updateDisplay();
                }
            };

On Feb 19, 10:18 am, Harry <[email protected]> wrote:
> All,
> I really need some help. I must be doing something wrong here.
> I am totally new to Java and XML, but I have been programming for
> years in basic and  VB (for excel macros)
>
> I got through SDK the installation but did have problems that I
> managed to resolve, and posted here how I did it to help others. It
> did take me many tries.
>
> http://groups.google.com/group/android-beginners/search?hl=en&group=android-beginners&q=harry+%[email protected]%3e&qt_g=Search+this+group
>
> So, off I went into HelloWorld, and then HelloViews into
> "HelloAndroid, I'm a string". OK fine
> HelloLinearLayout - runs like a clock.
> HelloRelitiveLayout - no problem there either.
>
> I am stuck onHelloDatePicker, I did modify the main.XML, and the
> Imports on Java work. But I must be inserting the Jave code in the
> wrong places - I even found a 2007 Google version ofHelloDatePicker
> in all Java and that's runs fine.
>
> This is my confusion, in the Java file after I modify the main.XML per
> this link:
>
> http://developer.android.com/guide/tutorials/views/hello-datepicker.html
>
> step 3 confuses me as to where I insert the code.
> This is my step 3 and it doesn't seem to matter where I insert the
> step 4 code and do the imports.
>
> package com.harry.datepicker1;
>
> import java.util.Calendar;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.view.View;
> import android.widget.Button;
> import android.widget.TextView;
>
> public class HelloDatepicker1 extends Activity {
>     /** Called when the activity is first created. */
>         private TextView mDateDisplay;
>     private Button mPickDate;
>
>     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.main);
>
>         // capture our View elements
>         mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
>         mPickDate = (Button) findViewById(R.id.pickDate);
>
>         // add a click listener to the button
>         mPickDate.setOnClickListener(new View.OnClickListener() {
>             public void onClick(View v) {
>                 showDialog(DATE_DIALOG_ID);
>             }
>         });
>
>         // get the current date
>         final Calendar c = Calendar.getInstance();
>         mYear = c.get(Calendar.YEAR);
>         mMonth = c.get(Calendar.MONTH);
>         mDay = c.get(Calendar.DAY_OF_MONTH);
>
>         // display the current date
>         updateDisplay();
>     }
>
> So....where exactly do I insert step 4?
>
> Here is step 4:
>
> @Override
> protected Dialog onCreateDialog(int id) {
>     switch (id) {
>     case DATE_DIALOG_ID:
>         return new DatePickerDialog(this,
>                     mDateSetListener,
>                     mYear, mMonth, mDay);
>     }
>     return null;}
>
> The rest should follow easily after step 4 according to the tutorial -
> I need a hand.
> Can anyone post or e-mail me the completed code?
>
> Thanks so much.
> Harry

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to