Android Program – Date Activity

ANDROID FOR FRESHERS

Android Program Date Activity

Java Code(DateAct) 

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.Toast;

public class DateAct extends Activity {
static final int Dialog1=1;
int Year, month, date;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_date);
}

public void next(View v)

{
showDialog(Dialog1);
}

@Override
protected Dialog onCreateDialog(int id) {

{
return new DatePickerDialog(DateAct.this, listener2, Year, month, date);

}

}
// DatePickerDialog dd= new DatePickerDialog(Jobpost.this, listener2, Year, month, date);

 

private DatePickerDialog.OnDateSetListener listener2 = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Year = year;
month = monthOfYear+1;
date = dayOfMonth;
String dated= date + “/” + month + “/” + Year;
Toast.makeText(DateAct.this,dated, Toast.LENGTH_SHORT).show();

}
};

}

Layout XML Code(activity_date)

<?xml version=”1.0″ encoding=”utf-8″?>
<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:orientation=”vertical”
android:paddingLeft=”@dimen/activity_horizontal_margin”
android:paddingRight=”@dimen/activity_horizontal_margin”
android:paddingTop=”@dimen/activity_vertical_margin”
tools:context=”com.andro.tech.androidproject.DateAct”>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”@dimen/textsize”
android:layout_gravity=”center”
android:textStyle=”bold”
android:text=”@string/datetext”
android:layout_marginBottom=”120dp” />

<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”PICK DATE”
android:onClick=”next”
android:layout_marginBottom=”150dp”/>

<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/sourcecode”
android:background=”@color/bgcolor”
android:textStyle=”bold”
android:textColor=”@color/text”
android:onClick=”view1″/>

</LinearLayout>

Output

Android date picker java snippet code download     Android date picker java snippet code download

Android Date picker java snippet code download

Download Date Picker Source Code

For More Android Programs –Click Here

 

Follow Us – Never Miss Update

Fb/PageTwitterGoogle+InstagramPinterest 

 

Related Search

Android date picker java snippet code download, android date picker source code download, android date picker source code for beginners, date picker java code download android, date pick android snippet code download, android date pick snippet java code download

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Comments