It worked now. Thank you very much everyone. :) On Jun 22, 8:37 pm, Temitope Akinwande <[email protected]> wrote: > Looking through your code, I do not see where you are using > R.id.display, however I see R.id.dateDisplay > > If the problem is with R.id.dateDisplay, do you have any layout > defined that has the id dateDisplay? > Check in your res/layout folder > > -Tope > > On Tue, Jun 22, 2010 at 3:57 PM, Varun Khanduja <[email protected]> > wrote: > > 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. > > * Visithttp://www.pragmaticprogrammer.com/titles/ebandfor 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 <[email protected]> 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 <[email protected]> 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/ebandformorebook > >> > 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; > >> > > > ... > > 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 [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

