package endTime = (EditText) findViewById(R.id.endTime); location = (EditText)

package com.example.yasminanunez.timetable;import android.app.TimePickerDialog;import android.content.Intent;import android.icu.util.Calendar;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TimePicker;import android.widget.Toast;/** * Created by yasminanunez on 22/11/2017. */public class Adding extends AppCompatActivity { DatabaseHelper helper; private Button saveBtn, cancelBtn, startBtn, endBtn; private EditText title, startTime, endTime, location, classType, teacher; private int hour, minutes; String weekDay; Intent intent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.adding_main); title = (EditText) findViewById(R.id.title); startTime = (EditText) findViewById(R.id.startTime); endTime = (EditText) findViewById(R.id.endTime); location = (EditText) findViewById(R.id.location); classType = (EditText) findViewById(R.id.classType); teacher = (EditText) findViewById(R.id.teacher); saveBtn = (Button) findViewById(R.id.saveBtn); cancelBtn = (Button) findViewById(R.id.cancelBtn); startBtn = (Button) findViewById(R.id.startBtn); endBtn = (Button) findViewById(R.id.endBtn); helper = new DatabaseHelper(this); saveBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { intent = getIntent(); weekDay = getIntent().getStringExtra(“Day”); if(title.length() != 0){ SchoolClass schoolclass = new SchoolClass(title.getText().toString(), startTime.getText().toString(), endTime.getText().toString(), location.getText().toString(), classType.getText().toString(), teacher.getText().toString(), weekDay); helper.addData(schoolclass); finish(); } else{ toastMessage(“You must enter data”); } } }); cancelBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); } private boolean isEmpty(EditText etText) { if (etText.getText().toString().trim().length() > 0) return false; return true; } public void startClicked(View view){ final Calendar c = Calendar.getInstance(); hour = c.get(Calendar.HOUR_OF_DAY); minutes = c.get(Calendar.MINUTE); TimePickerDialog timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int i, int i1) { startTime.setText(i+”:”+i1); } }, hour, minutes, false); timePickerDialog.show(); } public void endClicked(View view){ final Calendar c = Calendar.getInstance(); hour = c.get(Calendar.HOUR_OF_DAY); minutes = c.get(Calendar.MINUTE); TimePickerDialog timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int i, int i1) { endTime.setText(i+”:”+i1); } }, hour, minutes, false); timePickerDialog.show(); } private void toastMessage(String message) { Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); }}

BACK TO TOP
x

Hi!
I'm Angelica!

Would you like to get a custom essay? How about receiving a customized one?

Check it out