I forgot the date and time picker arrrrrrrgh


I've added the following 2 classes which have no errors and seem to function fine.

DatePickerFragment.java
PHP Code:
package com.test.dfw;

import java.util.Calendar;

import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;
import android.widget.TextView;

public class 
DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener{

    
TextView txtDate;
    
    
     public 
DatePickerFragment(TextView txtDate) {
        
super();
        
this.txtDate txtDate;
    }

    @
Override
        
public Dialog onCreateDialog(Bundle savedInstanceState) {
            
// Use the current date as the default date in the picker
            
final Calendar c Calendar.getInstance();
            
int year c.get(Calendar.YEAR);
            
int month c.get(Calendar.MONTH);
            
int day c.get(Calendar.DAY_OF_MONTH);

            
// Create a new instance of DatePickerDialog and return it
            
return new DatePickerDialog(getActivity(), thisyearmonthday);
        }

        public 
void onDateSet(DatePicker viewint yearint monthint day) {
            
txtDate.setText(new StringBuilder().append(month 1)
                    .
append("-").append(day).append("-").append(year)
                    .
append(" "));
        }
    
    
    

TimePickerFragment.java
PHP Code:
package com.test.dfw;

import java.util.Calendar;

import android.app.Dialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.text.format.DateFormat;
import android.widget.TextView;
import android.widget.TimePicker;

public class 
TimePickerFragment extends DialogFragment  implements TimePickerDialog.OnTimeSetListener{
    
    
TextView txtTime;
    
    
    
    public 
TimePickerFragment(TextView txtTime) {
        
super();
        
this.txtTime txtTime;
    }

    @
Override
        
public Dialog onCreateDialog(Bundle savedInstanceState) {
            
// Use the current time as the default values for the picker
            
final Calendar c Calendar.getInstance();
            
int hour c.get(Calendar.HOUR_OF_DAY);
            
int minute c.get(Calendar.MINUTE);

            
// Create a new instance of TimePickerDialog and return it
            
return new TimePickerDialog(getActivity(), thishourminute,
                    
DateFormat.is24HourFormat(getActivity()));
        }

        public 
void onTimeSet(TimePicker viewint hourOfDayint minute) {
           
txtTime.setText(hourOfDay+":"+minute);
        }

I then updated BookNowFragment.java

PHP Code:
package com.test.dfw;

import java.util.Calendar;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.telephony.SmsManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;

public class 
BookNowFragment extends Fragment implements OnClickListener {

    
Button buttonSubmit;
    
EditText edittextPhone;
    
EditText editTextProblem;
    
Button btnChangeDate,btnChangeTime;
    
TextView txtDisplayDate,txtDisplayTime;
    
DatePicker datePicker;
    
TimePicker timePicker;
    
    private 
int year;
    private 
int month;
    private 
int day;
    
    private 
int hour;
    private 
int minute;

    public 
View onCreateView(LayoutInflater inflaterViewGroup container,
            
Bundle savedInstanceState) {

        final 
View rootView inflater.inflate(R.layout.fragment_booknow,
                
containerfalse);
        
        
showCurrentDateOnView();
        
showCurrentTimeOnView();

        
buttonSubmit = (ButtonrootView.findViewById(R.id.buttonSubmit);
        
// edittextPhone = (EditText) rootView.findViewById(R.id.edittextPhone);
        // editTextProblem = (EditText)
        // rootView.findViewById(R.id.editTextProblem);

        
buttonSubmit.setOnClickListener(new View.OnClickListener() {
            public 
void onClick(View v) {
                
String strPhoneNo "00000000";
                
TextView txtName = (TextViewrootView
                        
.findViewById(R.id.edittextName);
                
TextView txtPhone = (TextViewrootView
                        
.findViewById(R.id.edittextPhone);
                
//TextView txtDate = (TextView) rootView.findViewById(R.id.date);

                
TextView txtProblem = (TextViewrootView
                        
.findViewById(R.id.editTextProblem);
                
String strName "Name: " txtName.getText().toString();
                
String strPhone "Phone: " txtPhone.getText().toString();
                
//String strDate = "Date: " + txtDate.getText().toString();

                
String strProblem "Problem: "
                        
txtProblem.getText().toString();
                
String strMessage strName "\n" strPhone "\n" strProblem;

                
BookNowSMS(strPhoneNostrMessage);
            }
        });

        return 
rootView;
    }

    
// ---sends a SMS message to another device---
    
private void BookNowSMS(String phoneNumberString message) {

        
/*
         * PendingIntent pi = PendingIntent.getActivity(this, 0, new
         * Intent(this, test.class), 0); SmsManager sms =
         * SmsManager.getDefault(); sms.sendTextMessage(phoneNumber, null,
         * message, pi, null);
         */

        
String SENT "SMS_SENT";
        
// String DELIVERED = "SMS_DELIVERED";

        
PendingIntent sentPI PendingIntent.getBroadcast(getActivity(), 0,
                new 
Intent(SENT), 0);

        
/*
         * PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new
         * Intent(DELIVERED), 0);
         */

        // ---when the SMS has been sent---
        
getActivity().registerReceiver(new BroadcastReceiver() {

            @
Override
            
public void onReceive(Context arg0Intent arg1) {
                switch (
getResultCode()) {
                case 
Activity.RESULT_OK:
                    
Toast.makeText(getActivity(), "Message Sent",
                            
Toast.LENGTH_SHORT).show();
                    break;

                case 
SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                    
Toast.makeText(getActivity(), "Generic failure",
                            
Toast.LENGTH_SHORT).show();
                    break;

                case 
SmsManager.RESULT_ERROR_NO_SERVICE:
                    
Toast.makeText(getActivity(), "No service",
                            
Toast.LENGTH_SHORT).show();
                    break;

                case 
SmsManager.RESULT_ERROR_NULL_PDU:
                    
Toast.makeText(getActivity(), "Null PDU",
                            
Toast.LENGTH_SHORT).show();
                    break;

                case 
SmsManager.RESULT_ERROR_RADIO_OFF:
                    
Toast.makeText(getActivity(), "Radio off",
                            
Toast.LENGTH_SHORT).show();
                    break;
                }
            }
        }, new 
IntentFilter(SENT));

        
SmsManager sms SmsManager.getDefault();

        
sms.sendTextMessage(phoneNumbernullmessagesentPInull);

    }

    @
Override
    
public void onClick(View v) {
        
// TODO Auto-generated method stub

    
}

    
// display current date
            
public void showCurrentDateOnView() {
         
                
txtDisplayDate = (TextViewfindViewById(R.id.txtDate);
                
datePicker = (DatePickerfindViewById(R.id.datePicker1);
         
                final 
Calendar c Calendar.getInstance();
                
year c.get(Calendar.YEAR);
                
month c.get(Calendar.MONTH);
                
day c.get(Calendar.DAY_OF_MONTH);
         
                
// set current date into textview
                
txtDisplayDate.setText(new StringBuilder()
                    
// Month is 0 based, just add 1
                    
.append(month 1).append("-").append(day).append("-")
                    .
append(year).append(" "));
         
                
// set current date into datepicker
                
datePicker.init(yearmonthdaynull);
         
            }

            
            
// display current time
            
public void showCurrentTimeOnView() {
         
                
txtDisplayTime = (TextViewfindViewById(R.id.txtTime);
                
timePicker = (TimePickerfindViewById(R.id.timePicker1);
         
                final 
Calendar c Calendar.getInstance();
                
hour c.get(Calendar.HOUR_OF_DAY);
                
minute c.get(Calendar.MINUTE);
         
                
// set current time into textview
                
txtDisplayTime.setText(
                            new 
StringBuilder().append(hour)
                                               .
append(":").append(minute));
         
                
// set current time into timepicker
                
timePicker.setCurrentHour(hour);
                
timePicker.setCurrentMinute(minute);
         
            }
            
            
            public 
void showDatePickerDialog(View v) {
                
DialogFragment newFragment = new DatePickerFragment(txtDisplayDate);
                
newFragment.show(getSupportFragmentManager(), "datePicker");
            }
            
            public 
void showTimePickerDialog(View v) {
                
DialogFragment newFragment = new TimePickerFragment(txtDisplayTime);
                
newFragment.show(getSupportFragmentManager(), "timePicker");
            }
            
            
        @
Override
        
public boolean onCreateOptionsMenu(Menu menu) {
            
// Inflate the menu; this adds items to the action bar if it is present.
            
getMenuInflater().inflate(R.menu.activity_mainmenu);
            return 
true;
        }



The problem areas are all under BookNowFragment.java;

1. Under "showCurrentDateOnView" the both findViewById says undefined for the type.I have tried adding rootView but didnt work.

2. Under "showCurrentTimeOnView" both findViewById says undefined for the type.I have tried adding rootView but didnt work.

3. under "showDatePickerDialog" and "showTimePickerDialog" both the getSupportFragmentManager methods show the error "The method getSupportFragmentManager() is undefined for the type BookNowFragment"

4. I also have errors with "onCreateOptionsMenu".I worked out some of them by adding getActivity (see new code below) but it still shows the error "The method onCreateOptionsMenu(Menu) of type BookNowFragment must override or implement a supertype method"

PHP Code:
@Override
        
public boolean onCreateOptionsMenu(Menu menu) {
            
// Inflate the menu; this adds items to the action bar if it is present.
            
getActivity().getMenuInflater().inflate(R.menu.mainmenu);
            return 
true;
        } 
Think there simple issues although I'm simple as well so I could be understating it.
DEVICE: HTC Sensation (AUS)
ROM: Android Revolution HD 6.7.1 XE
Kernel: Faux123-v008b8
Radio: 11.76A.3504.00P_11.24A.3504.31_M
Recovery: 4EXT Touch
Recovery Theme: Miranda