I have received the following unexpected error while trying to run my activity:
Invalid type for value: class android.widget.TextView
Essentially I am trying to store data into Parse.com, where a user would select their calendar date and time through button clicks, and where the date and time selected would be recorded and shown into two TextViews that is displayed to them (Date and Time). Now I want to grab the TextViews information and record it into parse.
Below is the logcat message:
09-16 16:58:25.510: E/AndroidRuntime(1542): FATAL EXCEPTION: main
09-16 16:58:25.510: E/AndroidRuntime(1542): Process: com.dooba.beta, PID: 1542
09-16 16:58:25.510: E/AndroidRuntime(1542): java.lang.IllegalArgumentException: invalid type for value: class android.widget.TextView
09-16 16:58:25.510: E/AndroidRuntime(1542): at com.parse.ParseObject.put(ParseObject.java:2696)
09-16 16:58:25.510: E/AndroidRuntime(1542): at com.parse.ParseUser.put(ParseUser.java:404)
09-16 16:58:25.510: E/AndroidRuntime(1542): at com.dooba.beta.ScheduleMatchOptionActivity$1.onClick(ScheduleMatchOptionActivity.java:55)
09-16 16:58:25.510: E/AndroidRuntime(1542): at android.view.View.performClick(View.java:4438)
09-16 16:58:25.510: E/AndroidRuntime(1542): at android.view.View$PerformClick.run(View.java:18422)
09-16 16:58:25.510: E/AndroidRuntime(1542): at android.os.Handler.handleCallback(Handler.java:733)
09-16 16:58:25.510: E/AndroidRuntime(1542): at android.os.Handler.dispatchMessage(Handler.java:95)
09-16 16:58:25.510: E/AndroidRuntime(1542): at android.os.Looper.loop(Looper.java:136)
09-16 16:58:25.510: E/AndroidRuntime(1542): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-16 16:58:25.510: E/AndroidRuntime(1542): at java.lang.reflect.Method.invokeNative(Native Method)
09-16 16:58:25.510: E/AndroidRuntime(1542): at java.lang.reflect.Method.invoke(Method.java:515)
09-16 16:58:25.510: E/AndroidRuntime(1542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-16 16:58:25.510: E/AndroidRuntime(1542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-16 16:58:25.510: E/AndroidRuntime(1542): at dalvik.system.NativeStart.main(Native Method)
Below is the Activity code
public class ScheduleMatchOptionActivity extends Activity implements
OnClickListener {
protected TextView mCalendarDate;
protected TextView mCalendarTime;
Button btnCalendar, btnTimePicker;
TextView txtDate, txtTime;
private int mYear, mMonth, mDay, mHour, mMinute;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.match_schedule);
txtDate = (TextView) findViewById(R.id.txtDate);
txtTime = (TextView) findViewById(R.id.txtTime);
Button mConfirm2 = (Button)findViewById(R.id.btnConfirmSchedule);
mConfirm2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ParseUser currentUser = ParseUser.getCurrentUser();
// Create the class and the columns
currentUser.saveInBackground();
currentUser.put("ActivityDate", txtDate);
currentUser.put("ActivityTime", txtTime);
currentUser.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
setProgressBarIndeterminateVisibility(false);
if (e == null) {
// Success!
}
else {
}
}
});
}
});
btnCalendar = (Button) findViewById(R.id.btnCalendar);
btnTimePicker = (Button) findViewById(R.id.btnTimePicker);
txtDate = (TextView) findViewById(R.id.txtDate);
txtTime = (TextView) findViewById(R.id.txtTime);
btnCalendar.setOnClickListener(this);
btnTimePicker.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == btnCalendar) {
// Process to get Current Date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// Display Selected date in textbox
txtDate.setText(dayOfMonth + "-"
+ (monthOfYear + 1) + "-" + year);
}
}, mYear, mMonth, mDay);
dpd.show();
}
if (v == btnTimePicker) {
// Process to get Current Time
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
// Launch Time Picker Dialog
TimePickerDialog tpd = new TimePickerDialog(this,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
// Display Selected time in textbox
txtTime.setText(hourOfDay + ":" + minute);
}
}, mHour, mMinute, false);
tpd.show();
}
}
}
If you require any additional information, or clarification, let me know.