Back to project page ProjectStudio.
The source code is released under:
Apache License
If you think the Android project ProjectStudio listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** */*from www . j a v a 2s . c o m*/ */ package fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.widget.DrawerLayout; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import com.example.uniutilproject.R; import java.util.Calendar; import dialog_fragments.DatePickerDialogFragment; import dialog_fragments.TimePickerDialogFragment; /** * @author desmond */ public class StudyPlanFragment extends Fragment { private EditText plan_name_editText; private EditText coursename_editText; private EditText location_editText; private TextView date_textview; private TextView time_textview; private Button create_button; private View view; private DrawerLayout parent_drawer; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.studyplan_fragment, container, false); //IF DRAWER HAS BEEN DISABLED BY SOME OTHER FRAGMENT //ENABLE DRAWER parent_drawer = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout); if (parent_drawer.getDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) == 0){ parent_drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); } //INFLATE VIEWS HERE if (view != null) { plan_name_editText = (EditText) view .findViewById(R.id.card_task_title); } if (view != null) { coursename_editText = (EditText) view .findViewById(R.id.task_et); } if (view != null) { location_editText = (EditText) view .findViewById(R.id.task_location_et); } if (view != null) { date_textview = (TextView) view.findViewById(R.id.task_dateView); date_textview.setOnClickListener(new DatePickerListener()); } if (view != null) { time_textview = (TextView) view.findViewById(R.id.task_timeView); time_textview.setOnClickListener(new TimePickerListener()); } return view; } // SET DEFAULT DATE ON TEXTVIEW TO BE THE CURRENT DATE public void setCurrentDate(TextView date_textview) { final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int date = c.get(Calendar.DATE); date_textview.setText(new StringBuilder().append(month + 1).append("-") .append(date).append("-").append(year)); } //SET DEFAULT TIME ON TEXTVIEW TO BE THE CURRENT DATE public void setCurrentTime(TextView time_textview) { final Calendar c = Calendar.getInstance(); int hourOfDay = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); if (hourOfDay > 12) { time_textview.setText(new StringBuilder().append(hourOfDay) .append(":").append(minute).append("pm").append("")); } else { time_textview.setText(new StringBuilder().append(hourOfDay) .append(":").append(minute).append("am").append("")); } } // SHOW THE DATEPICKER DIALOG FRAGMENT public void showDatePickerFragment(View v) { DatePickerDialogFragment datepicker = new DatePickerDialogFragment( date_textview); datepicker.show(getFragmentManager(), "datePicker_studyplan"); } //SHOW THE TIMEPICKER DIALOG FRAGMENT public void showTimePickerFragment(View v) { TimePickerDialogFragment timepicker = new TimePickerDialogFragment(time_textview); timepicker.show(getFragmentManager(), "timePicker_studyplan"); } //delete when done private class TimePickerListener implements OnClickListener { @Override public void onClick(View v) { showTimePickerFragment(v); } } private class DatePickerListener implements OnClickListener { @Override public void onClick(View v) { showDatePickerFragment(v); } } }