I've been Trying to create an Android application which able to select multiple days from the calendar, and display first and last Dates of the selection in different TextViews and Update that event in a Firestore Database.
this is the Calendar Activity class
CalendarActivity.Java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.squareup.timessquare.CalendarPickerView;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class CalendarActivity extends AppCompatActivity {
String eventStartDate ;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final CalendarPickerView calendar_view = (CalendarPickerView)
findViewById(R.id.calendar_view);
//getting currentS
Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 1);
Date today = new Date();
//add one year to calendar from todays date
calendar_view.init(today, nextYear.getTime())
.inMode(CalendarPickerView.SelectionMode.RANGE);
//action while clicking on a date
calendar_view.setOnDateSelectedListener(new
CalendarPickerView.OnDateSelectedListener() {
#Override
public void onDateSelected(Date date) {
Toast.makeText(getApplicationContext(),"Selected Date is : " +date.toString(),Toast.LENGTH_SHORT).show();
eventStartDate=date.toString();
}
#Override
public void onDateUnselected(Date date) {
//...
}
});
//fetch dates
final List<Date> dates = calendar_view.getSelectedDates();
//final int eventEndDateIndex = dates.lastIndexOf(dates);
//eventStartDate = dates.get(0);
//eventEndDate= dates.get(eventEndDateIndex);
//Displaying all selected dates while clicking on a button
Button btn_show_dates = (Button) findViewById(R.id.btn_show_dates);
btn_show_dates.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int j=0;
for (int i = 0; i< calendar_view.getSelectedDates().size();i++){
//here you can fetch all dates
Toast.makeText(getApplicationContext(),calendar_view.getSelectedDates().get(i).toString(),Toast.LENGTH_SHORT).show();
}
}
});
}
}
And this is the Layout File
activity_calendar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CalendarActivity">
<com.squareup.timessquare.CalendarPickerView
android:id="#+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="467dp"
android:layout_above="#+id/btn_show_dates"
android:layout_alignParentTop="true"
android:background="#FFFFFF"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay" />
<Button
android:id="#+id/btn_show_dates"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Display Dates"
android:background="#color/colorPrimary"
android:textColor="#FFFFFF"/>
<TextView
android:id="#+id/eventStartDate"
android:layout_width="107dp"
android:layout_height="23dp"
android:text="Event Start Date"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="472dp" />
<TextView
android:id="#+id/eventEndDate"
android:layout_width="116dp"
android:layout_height="23dp"
android:text="Event End Date"
tools:layout_editor_absoluteX="252dp"
tools:layout_editor_absoluteY="472dp" />
</android.support.constraint.ConstraintLayout>
You have a list of selected days as Date objects:
calendar_view.getSelectedDates();
Using a compare function such as:
Collections.sort(your_dates, new Comparator<Date>() {
#Override
public int compare(Date d1, Date d2) {
if(d1.getTime() > d2.getTime())
return 1;
else if(d1.getTime() < d2.getTime())
return -1;
return 0;
}
});
Then you can just access the first and last element of the list.
Related
I have two textviews and two buttons. When you click on the first button, a window with a choice of time opens. You select the time and it is displayed in textview1. Similarly with the second button and textview2. Now the main task is to sum this time and when you click on the Sum button, display the sum of the time in TextView3 (textview1 + textview2). any ideas how to implement this? preferably with code
XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is First Activity"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Go to Second Activity"
android:id="#+id/btnActTwo"
android:onClick="onClick">
</Button>
<TextView
android:id="#+id/viewTime1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Time1" />
<Button
android:id="#+id/time1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Choose Time 1"
android:onClick="setTime"/>
<TextView
android:id="#+id/viewTime2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Time2" />
<Button
android:id="#+id/time2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Choose Time 2"
android:onClick="setTime2"
/>
<TextView
android:id="#+id/sum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sum" />
<Button
android:id="#+id/btnSum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SUM"
android:onClick="onClick2"/>
</LinearLayout>
And Main.java code:
package com.example.myapplication_lab4;
import androidx.appcompat.app.AppCompatActivity;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
TextView viewTime1;
TextView viewTime2;
TextView sum;
Button time1;
Button time2;
Button btnSum;
Calendar dateAndTime=Calendar.getInstance();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewTime1 = (TextView) findViewById(R.id.viewTime1);
viewTime2 = (TextView) findViewById(R.id.viewTime2);
sum = (TextView) findViewById(R.id.sum);
time1 = (Button) findViewById(R.id.time1);
time2 = (Button) findViewById(R.id.time2);
btnSum = (Button) findViewById(R.id.btnSum);
}
// display a dialog box for selecting the time for 1
public void setTime(View v) {
new TimePickerDialog(MainActivity.this, t,
dateAndTime.get(Calendar.HOUR_OF_DAY),
dateAndTime.get(Calendar.MINUTE), true)
.show();
}
// display a dialog box for selecting the time for 2
public void setTime2(View v) {
new TimePickerDialog(MainActivity.this, t2,
dateAndTime.get(Calendar.HOUR_OF_DAY),
dateAndTime.get(Calendar.MINUTE), true)
.show();
}
// setting start time for 1
private void setInitialDateTime() {
viewTime1.setText(DateUtils.formatDateTime(this,
dateAndTime.getTimeInMillis(),
DateUtils.FORMAT_SHOW_TIME));
}
// setting start time for 2
private void setInitialDateTime2() {
viewTime2.setText(DateUtils.formatDateTime(this,
dateAndTime.getTimeInMillis(),
DateUtils.FORMAT_SHOW_TIME));
}
// setting the time picker for 1
TimePickerDialog.OnTimeSetListener t = new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
dateAndTime.set(Calendar.MINUTE, minute);
setInitialDateTime();
}
};
// setting the time picker for 2
TimePickerDialog.OnTimeSetListener t2 = new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
dateAndTime.set(Calendar.MINUTE, minute);
setInitialDateTime2();
}
};
//irrelevant to the issue
//Click to go to Activity 2
public void onClick(View view) {
Button btnActTwo;
btnActTwo = (Button) findViewById(R.id.btnActTwo);
if (view.getId() == R.id.btnActTwo) {//call sec act
Intent intent = new Intent(this, Activity2.class);
startActivity(intent);
}
}
public void onClick2(View view) {
}
}
Here is sample code of sum two date.
String time1="0:30:32";
String time2="0:35:20";
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
timeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date1 = timeFormat.parse(time1);
Date date2 = timeFormat.parse(time2);
long sum = date1.getTime() + date2.getTime();
String date3 = timeFormat.format(new Date(sum));
Log.e("TAG", "Date sum is => " + date3);
**Output: ** Date sum is => 01:05:52
How to make a date picker with multiple date selecting options in Android Studio using Java?
With naitive DatePicker you can't.
if you want multiple select, you can use library.
you can try to use this library or libraries
implementation 'com.savvi.datepicker:rangepicker:1.3.0'
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.savvi.rangedatepicker.CalendarPickerView
android:id="#+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:scrollbarStyle="outsideOverlay"
app:tsquare_orientation_horizontal="false"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"/>
<Button
android:id="#+id/get_selected_dates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selected Dates"
tools:layout_editor_absoluteX="229dp"
tools:layout_editor_absoluteY="447dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dateselected"/>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.savvi.rangedatepicker.CalendarPickerView;
import com.savvi.rangedatepicker.SubTitle;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import androidx.appcompat.app.AppCompatActivity;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
CalendarPickerView calendar;
Button button;
private TextView datesSelected;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
datesSelected=(TextView)findViewById(R.id.dateselected);
final Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 10);
final Calendar lastYear = Calendar.getInstance();
lastYear.add(Calendar.YEAR, - 10);
calendar = findViewById(R.id.calendar_view);
button = findViewById(R.id.get_selected_dates);
ArrayList<Integer> list = new ArrayList<>();
list.add(4);
//calendar.deactivateDates(list);
ArrayList<Date> arrayList = new ArrayList<>();
SimpleDateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy");
calendar.init(lastYear.getTime(), nextYear.getTime(), new SimpleDateFormat("MMMM, YYYY", Locale.getDefault())) //
.inMode(CalendarPickerView.SelectionMode.MULTIPLE);
calendar.scrollToDate(new Date());
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//Toast.makeText(MainActivity.this, "list " + calendar.getSelectedDates(), Toast.LENGTH_LONG).show();
datesSelected.setText("");
ArrayList<Date>selectedDates = (ArrayList<Date>)calendar.getSelectedDates();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
for(int i = 0; i< selectedDates.size(); i++)
{
Date tempDate = selectedDates.get(i);
String formattedDate = sdf.format(tempDate);
datesSelected.append(formattedDate);
//Toast.makeText(MainActivity.this, "list " + formattedDate, Toast.LENGTH_LONG).show();
//Following if is added to avoid adding comma after the last date.
datesSelected.append("<br/>");
}
}
});
}
private ArrayList<SubTitle> getSubTitles() {
final ArrayList<SubTitle> subTitles = new ArrayList<>();
final Calendar tmrw = Calendar.getInstance();
tmrw.add(Calendar.DAY_OF_MONTH, 1);
subTitles.add(new SubTitle(tmrw.getTime(), "₹1000"));
return subTitles;
}
}
```
I new to Android Studio, and would like to know how to switch to another activity after clicking a date using a DatePicker? Or, at the very least, make text appear on the screen after clicking a date. I have read the documentation for DatePicker and looked at some tutorials and for some reason, I am still lost on this. Any advice would be greatly appreciated.
(Edit)
Alright, so I did some more work and found out I was missing an OnClickListener. The problem now is the text for date only changes if I click on the border of the DatePicker and not the actual date.
Currently, my code is as follows:
activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.wes19_000.working_on_it.MainMenu">
<DatePicker
android:id="#+id/datePicker2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="18dp"
tools:layout_editor_absoluteY="16dp"
tools:ignore="MissingConstraints"
android:clickable="true"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dateText"
tools:layout_editor_absoluteX="162dp"
tools:layout_editor_absoluteY="461dp"
tools:ignore="MissingConstraints" />
</android.support.constraint.ConstraintLayout>
MainMenu.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.TextView;
public class MainMenu extends AppCompatActivity implements View.OnClickListener {
private DatePicker datePicker;
private TextView dateText;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
datePicker = (DatePicker) findViewById(R.id.datePicker2);
datePicker.setOnClickListener(this);
dateText = (TextView)findViewById(R.id.textView2);
}
#Override
public void onClick(View v) {
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth();
int year = datePicker.getYear();
String date = (month + 1) + "/" + day + "/" + year;
dateText.setText(date);
}
}
DatePicker supports a listener, but you need to initialize the date picker in order to use the listener.
datePicker.init(2000,6,15, new DatePicker.OnDateChangedListener(){...});
See the documentation for more details.
How can I get the dates a user has chosen to and from in my datepicker each time. The user will press a button to open the calendar, then chooses the dates from and to. After this is chosen the dates get appended to a TextView. But how can I get the dates each time to store into a variable as I will need to use each date as a value.?
Tab2 class:
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.Toast;
import com.borax12.materialdaterangepicker.date.DatePickerDialog;
import java.util.Calendar;
/**
* Created by hp1 on 21-01-2015.
*/
public class Tab2 extends Fragment implements DatePickerDialog.OnDateSetListener{
DatePicker pickerDate;
TextView dateTextView;
private boolean mAutoHighlight;
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.tab2,container,false);
Button dateButton = (Button)v.findViewById(R.id.button2);
dateTextView = (TextView)v.findViewById(R.id.textView5);
CheckBox ahl = (CheckBox) v.findViewById(R.id.autohighlight_checkbox);
ahl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mAutoHighlight = b;
}
});
// Show a datepicker when the dateButton is clicked
dateButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Calendar now = Calendar.getInstance();
DatePickerDialog dpd = com.borax12.materialdaterangepicker.date.DatePickerDialog.newInstance(
Tab2.this,
now.get(Calendar.YEAR),
now.get(Calendar.MONTH),
now.get(Calendar.DAY_OF_MONTH)
);
dpd.setAutoHighlight(mAutoHighlight);
dpd.show(getActivity().getFragmentManager(), "Datepickerdialog");
}
});
return v;
}
#Override
public void onResume() {
super.onResume();
DatePickerDialog dpd = (DatePickerDialog) getActivity().getFragmentManager().findFragmentByTag("Datepickerdialog");
if(dpd != null) dpd.setOnDateSetListener(this);
}
#Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {
String date = "You picked the following date: From- "+dayOfMonth+"/"+(++monthOfYear)+"/"+year+" To "+dayOfMonthEnd+"/"+(++monthOfYearEnd)+"/"+yearEnd;
dateTextView.append(date + "\n");
}
Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<CheckBox
android:id="#+id/autohighlight_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"/>
</LinearLayout>
Use OnDateSetListener. something like this
int year,monthofyear,dayofmonth;
dpd = new DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, monthOfYear);
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
preview.setText(new StringBuilder().append(year+"/")
.append(monthOfYear+"/").append(dayOfMonth));
}
};
I am making a time management application. What I am trying to do is have some information:
DatePicker=to select the date of an event
TimePicker=to select the time of an event
Couple EditTexts=to put in information about the event(length in minutes, title)
So I have all of this in an activity, and now I need to find a way that I can take all of this information and make it into a push notification which will notify me at the date selected and at the time selected and for the amount of time inputted. Please tell if this is possible. If it is not, then please tell me if I can find some other way to do something similar.
Here is my .java:
package net.mastersofdisasters2.timagement;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
import org.w3c.dom.Text;
import java.text.DateFormat;
import java.util.Calendar;
public class assignment extends Activity implements DatePicker.OnDateChangedListener
{
private TimePicker timePicker1;
private int hour;
private int minute;
static final int TIME_DIALOG_ID = 999;
// display current time
public void setCurrentTimeOnView() {
timePicker1 = (TimePicker) findViewById(R.id.timeofassignment);
final Calendar c = Calendar.getInstance();
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
// set current time into timepicker
timePicker1.setCurrentHour(hour);
timePicker1.setCurrentMinute(minute);
}
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case TIME_DIALOG_ID:
// set time picker as current time
return new TimePickerDialog(this,
timePickerListener, hour, minute,false);
}
return null;
}
private TimePickerDialog.OnTimeSetListener timePickerListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int selectedHour,
int selectedMinute) {
hour = selectedHour;
minute = selectedMinute;
// set current time into timepicker
timePicker1.setCurrentHour(hour);
timePicker1.setCurrentMinute(minute);
}
};
private static String pad(int c) {
if (c >= 10)
return String.valueOf(c);
else
return "0" + String.valueOf(c);
}
DatePicker dp=null;
Calendar cal=null;
TextView mcdate=null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_assignment);
Button button = (Button)findViewById(R.id.create_assignment);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(assignment.this,PushNotification.class));
}
});
enter code here
setCurrentTimeOnView();`enter code here`
dp=(DatePicker)findViewById(R.id.dateofassignment);
mcdate=(TextView)findViewById(R.id.enter_assignment_datetime);
cal=Calendar.getInstance();
dp.init(dp.getYear(),dp.getMonth(),dp.getDayOfMonth(),this);
}
public void onDateChanged(DatePicker dpview, int year, int monthOfYear, int dayOfMonth) {
cal.set(year, monthOfYear, dayOfMonth);
java.util.Date d = cal.getTime();
mcdate.setText(String.valueOf(d.getMonth() +1) + "/" + String.valueOf(d.getDate()) + "/" + String.valueOf((d.getYear() + 1900)));
}
}
Now that was just to add the DatePicker and TimePickers. Now what do I do to create a push notification from the inputted information?
Heres my activity.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#color/light_blue"
>
<TextView android:id="#+id/enter_assigment_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="#bool/abc_action_bar_embed_tabs"
android:text="#string/assignmentadd"
android:textSize="20sp"
android:textColor="#color/light_black"
/>
<EditText android:id="#+id/enter_assignment_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/assignmentadd"
android:layout_below="#id/enter_assigment_text"
android:paddingTop="10dp"
/>
<TextView
android:id="#+id/enter_assignment_datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/assignment_datetime"
android:layout_below="#+id/enter_assignment_field"
android:layout_marginTop="10dp"
android:textSize="20sp"
android:textColor="#color/light_black"/>
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/enter_assignment_field"
android:id="#+id/dateofassignment"
android:layout_marginTop="30dp">
</DatePicker>
<TextView android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/dateofassignment"
android:layout_marginTop="10dp"
android:text="#string/thechosendate"
/>
<TimePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/timeofassignment"
android:layout_below="#+id/date"
android:layout_marginTop="10dp">
</TimePicker>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/choose_assignment_length"
android:layout_below="#+id/timeofassignment"
android:layout_marginTop="10dp"
android:text="#string/length_of_assignment">
</TextView>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/enter_assignment_length"
android:hint="#string/length_of_assignment"
android:layout_below="#+id/choose_assignment_length"
android:layout_marginTop="10dp"/>
<Button android:id="#+id/create_assignment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/enter_assignment_length"
android:layout_centerHorizontal="true"
android:text="#string/submit"
android:background="#color/cornflower_blue"
/>
</RelativeLayout>
Please Help quickly I need to finish this very soon