Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

pleae no hand write and make sure to folow the instroction at the end Build “Dat

ID: 3598881 • Letter: P

Question

pleae no hand write and make sure to folow the instroction at the end

Build “Date Picker” in Android studio. It should allow you to select day, month and year through its interface after the click of a button “PICK DATE” and then display it in a text view. The following screenshots show the final output.

Instructions:

You can build the date picker dialog as shown in chapter 4, or you can directly use the DatePickerDialog class provided in Android. To use this, you need to read extra resources over the Web.

Name your app with your name

Name the activities/java files as follows: yourname_classname

You should submit the following in the assignment file:

Screenshots of your app

Copy the whole xml code of your layout file(s).

Copy of the whole java code of the relevant classes

my name is tariq al momatten

class name mobil application

CalendarView CalendarView CalendarView 2017 PICK DATE PICK DATE Wed, Oct 11 Oct 11, 2017 October 2017> SMTWTFS 910 156 17 18 19 2021 22 23 25 27 28 29 30 3 12 14 CANCELOK

Explanation / Answer

Created everything as per your requirements. Created an Android app with the name Tariq Al Momatten and an activity called TariqAlMomattenMobileApplication.java with the xml layout file activity_tariq_al_momatten_mobile_application.xml. Created a button, a DatePickerDialog and a TextView. When the button is clicked, date picker dialog will popup and when the user selects a date, it’ll be displayed in the textview. I’m attaching the Activity java file, xml layout file and screenshots. You may change the package name accordingly when you run the code. Thanks

//TariqAlMomattenMobieApplication.java file

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class TariqAlMomattenMobileApplication extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {
    Button datePickerButon; /*button to be clicked*/
   
DatePickerDialog dialog; /*DatePickerDialog object to be shown when the button is clicked*/
   
TextView dateText; /*Textview displaying selected date*/

   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tariq_al_momatten_mobile_application);
        /**
         * Initializing the required variables
         */
       
datePickerButon= (Button) findViewById(R.id.btnDatePicker);
        dialog=new DatePickerDialog(this,this, Calendar.getInstance().get(Calendar.YEAR),Calendar.getInstance().get(Calendar.MONTH),Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
        dateText= (TextView) findViewById(R.id.dateText);
        datePickerButon.setOnClickListener(new View.OnClickListener() {
            /**
             * Adding a listener to the button, so that the dialog will be
             * opened on click.
             */
           
@Override
            public void onClick(View view) {
                dialog.show(); /*showing the date picker dialog*/

           
}
        });

    }

    @Override
    public void onDateSet(DatePicker datePicker, int year, int month, int day) {
        /**
         * this callback method will be triggered when the user sets a date
         */
       
if(dateText!=null){
            /**
             * Checking if the textview is null
             */

           
Calendar calendar=Calendar.getInstance();
            calendar.set(year,month,day);
            /**
             * using a calendar instance to set the selected date; for formatting purposes
             */

           
dateText.setText(""+new SimpleDateFormat("MMM dd,yyyy").format(calendar.getTime()));
            /***
             * this will display the date in MMM dd,yyyy format: Ex: OCT 11,2017
             */

       
}
    }
}

//activity_tariq_al_momatten_mobile_application.xml