title: TimePickerDialog in Android
body: <p>I am trying to implement a simple TimePickerDialog in Android, but I am getting error. I am following this tutorial from Google: <a href="https://developer.android.com/guide/topics/ui/controls/pickers.html" rel="nofollow noreferrer">https://developer.android.com/guide/topics/ui/controls/pickers.html</a></p>
  
  <p>In my code, I have a button called setFromTimeButton that when clicked should display a DialogFragment with the TimePicker view, however, I have a compilation error:</p>
  
  <pre><code>Cannot resolve symbol TimePickerFragment()
  </code></pre>
  
  <p>Would you know why? Thank you!</p>
  
  <p>This is my class:</p>
  
  <pre><code>package it.bitrack.fabio.bitrack;
  
  import android.content.Context;
  import android.net.Uri;
  import android.os.Bundle;
  //import android.app.Fragment;
  import android.support.v4.app.DialogFragment;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import java.util.List;
  
  import android.app.Dialog;
  import android.text.format.DateFormat;
  
  import android.app.TimePickerDialog;
  import android.app.DatePickerDialog;
  
  import android.icu.util.Calendar;
  import android.widget.DatePicker;
  import android.widget.TimePicker;
  
  import android.widget.Button;
  import android.widget.TextView;
  
  
  /**
   * A simple {@link Fragment} subclass.
   * Activities that contain this fragment must implement the
   * {@link ScheduleView.OnFragmentInteractionListener} interface
   * to handle interaction events.
   * Use the {@link ScheduleView#newInstance} factory method to
   * create an instance of this fragment.
   */
  public class ScheduleView extends DialogFragment implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
      // TODO: Rename parameter arguments, choose names that match
      // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
      private static final String ARG_PARAM1 = "param1";
      private static final String ARG_PARAM2 = "param2";
  
      Button setFromTimeButton;
  
      android.support.v4.app.FragmentManager fragmentManager;
  
      // TODO: Rename and change types of parameters
      private String mParam1;
      private String mParam2;
  
      private OnFragmentInteractionListener mListener;
  
      public ScheduleView() {
          // Required empty public constructor
      }
  
      /**
       * Use this factory method to create a new instance of
       * this fragment using the provided parameters.
       *
       * @param param1 Parameter 1.
       * @param param2 Parameter 2.
       * @return A new instance of fragment ScheduleView.
       */
      // TODO: Rename and change types and number of parameters
      public static ScheduleView newInstance(String param1, String param2) {
          ScheduleView fragment = new ScheduleView();
          Bundle args = new Bundle();
          args.putString(ARG_PARAM1, param1);
          args.putString(ARG_PARAM2, param2);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              mParam1 = getArguments().getString(ARG_PARAM1);
              mParam2 = getArguments().getString(ARG_PARAM2);
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View view = inflater.inflate(R.layout.fragment_schedule_view, container, false);
  
          setFromTimeButton = (Button) view.findViewById(R.id.setFromTimeButton);
  
          fragmentManager = getFragmentManager();
  
          setFromTimeButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  DialogFragment newFragment = new TimePickerFragment();
                  newFragment.show(fragmentManager, "timePicker");
              }
          });
  
  
          return view;
      }
  
  
      // TODO: Rename method, update argument and hook method into UI event
      public void onButtonPressed(Uri uri) {
          if (mListener != null) {
              mListener.onFragmentInteraction(uri);
          }
      }
  
      @Override
      public void onAttach(Context context) {
          super.onAttach(context);
          if (context instanceof OnFragmentInteractionListener) {
              mListener = (OnFragmentInteractionListener) context;
          } else {
              throw new RuntimeException(context.toString()
                      + " must implement OnFragmentInteractionListener");
          }
      }
  
      @Override
      public void onDetach() {
          super.onDetach();
          mListener = null;
      }
  
      @Override
      public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
  
      }
  
      @Override
      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
  
      }
  
      /**
       * This interface must be implemented by activities that contain this
       * fragment to allow an interaction in this fragment to be communicated
       * to the activity and potentially other fragments contained in that
       * activity.
       * &lt;p&gt;
       * See the Android Training lesson &lt;a href=
       * "http://developer.android.com/training/basics/fragments/communicating.html"
       * &gt;Communicating with Other Fragments&lt;/a&gt; for more information.
       */
      public interface OnFragmentInteractionListener {
          // TODO: Update argument type and name
          void onFragmentInteraction(Uri uri);
      }
  
  
      @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(), this, hour, minute,
                  DateFormat.is24HourFormat(getActivity()));
      }
  }
  </code></pre>