Thank you everyone. I resolved most of the issues with all the help from all the group members.
I have one last issue: R. id. display cannot be resolved. Couldn't find anything online to help. Any help would be appreciated. /*** * Excerpted from "Hello, Android!", * published by The Pragmatic Bookshelf. * Copyrights apply to this code. It may not be used to create training material, * courses, books, articles, and the like. Contact us if you are in doubt. * We make no guarantees that this code is fit for any purpose. * Visit http://www.pragmaticprogrammer.com/titles/eband for more book information. ***/ package org.example.sudoku; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import java.util.Calendar; import android.app.DatePickerDialog; import android.app.Dialog; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; import android.widget.Toast; public class sudoku extends Activity implements OnClickListener { 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(); // Set up click listeners for all the buttons View continueButton = findViewById(R.id.continue_button); continueButton.setOnClickListener(this); View newButton = findViewById(R.id.new_button); newButton.setOnClickListener(this); View aboutButton = findViewById(R.id.about_button); aboutButton.setOnClickListener(this); View exitButton = findViewById(R.id.exit_button); exitButton.setOnClickListener(this); } /** Called when the activity is first created. */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay); } return null; } // updates the date we display in the TextView private void updateDisplay() { mDateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(mMonth + 1).append("-") .append(mDay).append("-") .append(mYear).append(" ")); } // the callback received when the user "sets" the date in the dialog private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; updateDisplay(); } }; // ... public void onClick(View v) { switch (v.getId()) { case R.id.about_button: Intent i = new Intent(this, About.class); startActivity(i); break; // More buttons go here (if any) ... } } } On Jun 22, 8:56 am, DonFrench <dcfre...@gmail.com> wrote: > Well you can't have two onCreate methods -- that much is certain. So > fix that first and then work on the other problems. > > On Jun 21, 9:13 pm, Varun Khanduja <varunkhand...@gmail.com> wrote: > > > Thank you. > > > I resolved some of the issues and the number of errors are down to 3. > > > /*** > > * Excerpted from "Hello, Android!", > > * published by The Pragmatic Bookshelf. > > * Copyrights apply to this code. It may not be used to create > > training material, > > * courses, books, articles, and the like. Contact us if you are in > > doubt. > > * We make no guarantees that this code is fit for any purpose. > > * Visithttp://www.pragmaticprogrammer.com/titles/ebandformore book > > information. > > ***/ > > package org.example.sudoku; > > > import android.app.Activity; > > import android.content.Intent; > > import android.os.Bundle; > > import android.view.View; > > import android.view.View.OnClickListener; > > import java.util.Calendar; > > import android.app.DatePickerDialog; > > import android.app.Dialog; > > > import android.widget.Button; > > import android.widget.DatePicker; > > import android.widget.TextView; > > import android.widget.Toast; > > > public class sudoku extends Activity implements OnClickListener { > > > 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(); > > } > > > /** Called when the activity is first created. */ > > �...@override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main) ; > > > // Set up click listeners for all the buttons > > View continueButton = findViewById(R.id.continue_button); > > continueButton.setOnClickListener(this); > > View newButton = findViewById(R.id.new_button); > > newButton.setOnClickListener(this); > > View aboutButton = findViewById(R.id.about_button); > > aboutButton.setOnClickListener(this); > > View exitButton = findViewById(R.id.exit_button); > > exitButton.setOnClickListener(this); > > > } > > > �...@override > > protected Dialog onCreateDialog(int id) { > > switch (id) { > > case DATE_DIALOG_ID: > > return new DatePickerDialog(this, > > mDateSetListener, > > mYear, mMonth, mDay); > > } > > return null; > > } > > // updates the date we display in the TextView > > private void updateDisplay() { > > mDateDisplay.setText( > > new StringBuilder() > > // Month is 0 based so add 1 > > .append(mMonth + 1).append("-") > > .append(mDay).append("-") > > .append(mYear).append(" ")); > > } > > > // the callback received when the user "sets" the date in the > > dialog > > private DatePickerDialog.OnDateSetListener mDateSetListener = > > new DatePickerDialog.OnDateSetListener() { > > > public void onDateSet(DatePicker view, int year, > > int monthOfYear, int dayOfMonth) > > { > > mYear = year; > > mMonth = monthOfYear; > > mDay = dayOfMonth; > > updateDisplay(); > > } > > }; > > // ... > > public void onClick(View v) { > > switch (v.getId()) { > > case R.id.about_button: > > Intent i = new Intent(this, About.class); > > startActivity(i); > > break; > > // More buttons go here (if any) ... > > > } > > } > > > } > > > Now the errors are as follows, in case you could help it would be kind > > of you. > > > 1. R.id.display cannot be resolved. > > 2. Duplicate method onCreate(Bundle) in type sudoku > > 3. Duplicate method onCreate(Bundle) in type sudoku. > > > I tried deleting one of the the on create but it was giving more > > errors. > > > On Jun 21, 1:48 pm, Temitope Akinwande <takinwa...@gmail.com> wrote: > > > > Most of the issues you are having are similar. > > > I don't see where your variables are defined, they are instantiated > > > but not defined anywhere. > > > Seehttp://developer.android.com/guide/tutorials/views/hello-datepicker.html > > > > private int mYear; > > > private int mMonth; > > > private int mDay; > > > > static final int DATE_DIALOG_ID = 0; > > > > Hope this helps some. > > > -Tope > > > > On Mon, Jun 21, 2010 at 9:53 AM, Varun Khanduja <varunkhand...@gmail.com> > > > wrote: > > > > > Hi, > > > > > I am new to Android development, I have started to learn Java. However > > > > as a beginner I am facing some issues. Here is the problem, your help > > > > will be much appreciated. I started learning Java from and use Hello > > > > android book to teach me some Java coding. Although what I have > > > > learned from book has worked so far, however I tried to incorporate a > > > > extra functionality of date-picker to see how I can use the Android > > > > documentation and apply date picker functionality. > > > > > Here are the list of problems I am facing > > > > > 1. DATE_DIALOG_ID cannot be resolved. > > > > 2. mDateDisplay cannot be resolved. > > > > 3. mDay cannot be resolved > > > > 4. mMonth cannot be resolved. > > > > 5. mPickDate cannot be resolved > > > > 6. Text view cannot be resolved to a type > > > > 7. R.id.display cannot be resolved. > > > > > Please help if your time permits. Thank you very much. > > > > > package org.example.sudoku; > > > > > import android.app.Activity; > > > > import android.content.Intent; > > > > import android.os.Bundle; > > > > import android.view.View; > > > > import android.view.View.OnClickListener; > > > > import java.util.Calendar; > > > > import android.app.DatePickerDialog; > > > > import android.app.Dialog; > > > > > import android.widget.Button; > > > > import android.widget.DatePicker; > > > > import android.widget.Toast; > > > > > public class sudoku extends Activity implements OnClickListener { > > > > > /** Called when the activity is first created. */ > > > > @Override > > > > public 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(); > > > > > // Set up click listeners for all the buttons > > > > View continueButton = findViewById(R.id.continue_button); > > > > continueButton.setOnClickListener(this); > > > > View newButton = findViewById(R.id.new_button); > > > > newButton.setOnClickListener(this); > > > > View aboutButton = findViewById(R.id.about_button); > > > > aboutButton.setOnClickListener(this); > > > > View exitButton = findViewById(R.id.exit_button); > > > > exitButton.setOnClickListener(this); > > > > > } > > > > @Override > > > > protected Dialog onCreateDialog(int id) { > > > > switch (id) { > > > > case DATE_DIALOG_ID: > > > > return new DatePickerDialog(this, > > > > mDateSetListener, > > > > mYear, mMonth, mDay); > > > > } > > > > return null; > > > > } > > > > // updates the date we display in the TextView > > > > private void updateDisplay() { > > > > mDateDisplay.setText( > > > > new StringBuilder() > > > > // Month is 0 based so add 1 > > > > .append(mMonth + 1).append("-") > > > > .append(mDay).append("-") > > > > .append(mYear).append(" ")); > > > > } > > > > > // the callback received when the user "sets" the date in the > > > > dialog > > > > private DatePickerDialog.OnDateSetListener mDateSetListener = > > > > new DatePickerDialog.OnDateSetListener() { > > > > > public void onDateSet(DatePicker view, int > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en