Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I'm completely new to programming on the Android platform but I'm interested in learning more of it. At the moment I'm doing this with the aid of a step by step handbook. Just to get myself familiar with the programming environment. I have knowledge of the Java language although I would not go as far by saying I'm good at it.
As for the problem, what I'm creating is a simple trivia game for Android devices. On a settings screen I am using a DatePickerDialog for the users birthday. Only when I run it on my Android device (Samsung Galaxy S i9000) or an emulator it crashes when trying to popup the DatePickerDialog.
The code I use is:
final TextView dob = (TextView) findViewById(R.id.TextView_DOB_Info); DatePickerDialog dateDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Time dateOfBirth = new Time(); dateOfBirth.set(dayOfMonth, monthOfYear, year); long dtDob = dateOfBirth.toMillis(true); dob.setText(DateFormat.format("MMMM dd, yyyy", dtDob)); Editor editor = mGameSettings.edit(); editor.putLong(GAME_PREFERENCES_DOB, dtDob); editor.commit(); } }, 0, 0, 0); return dateDialog;
Can anyone see if I'm doing something wrong here? When running I get an IllegalArgumentException in that method. I'm using Eclipse to program for Android, but I'm also fairly new to the program (I'm more familiar with Netbeans), I'm still trying to figure out how to properly debug through the Android app.
If anyone can help it will be greatly appreciated! Kind Regards, Floris
EDIT: As per request I added the LogCat lines:
09-16 18:42:22.386: ERROR/AndroidRuntime(20074): FATAL EXCEPTION: main 09-16 18:42:22.386: ERROR/AndroidRuntime(20074): java.lang.IllegalArgumentException: current should be >= start and <= end 09-16 18:42:22.386: ERROR/AndroidRuntime(20074): at android.widget.NumberPicker.setCurrent(NumberPicker.java:362) 09-16 18:42:22.386: ERROR/AndroidRuntime(20074): at android.widget.DatePicker.updateDaySpinner(DatePicker.java:487) 09-16 18
I've never used DatePickerDialog but as far as I can tell, you're using 0, 0, 0 as the year, month of year and day of month parameters. Set these to be something logical like 2011, 9, 16 and see if that helps.
DatePickerDialog
0, 0, 0
2011, 9, 16
EDIT Actually you may have to use 10 for September as I think it conforms to the 0-11 month numbers used by Calendar.
10
Calendar
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.