[android-developers] Re: android Date picker

2011-08-10 Thread syed akhtar ali
try this code:
change the package name.
package com.start;

import java.util.Calendar;

import com.start.R.id;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;

public class Register extends Activity {
 private TextView mDateDisplay;
private Button mPickDate;
private int mMonth;
private int mDay;
private int mYear;
private TextView mTimeDisplay;
private Button mPicktime;
private EditText autocomplete;
 static final int  DATE_DIALOG_ID=0;
private static final String[] COUNTRIES = null;



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.register);

mDateDisplay = (TextView)  findViewById(R.id.datedisplay);
mPickDate = (Button) findViewById(R.id.pickdate);
mTimeDisplay = (TextView) findViewById(R.id.timeDisplay);
mPicktime = (Button) findViewById(R.id.pickTime);
mPickDate.setOnClickListener(new View.OnClickListener() {


public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}


});
Button Button = (Button)findViewById(R.id.pickTime);
Button.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
Intent intent = new 
Intent(Register.this,Time.class);
startActivity(intent);
}
});

// to get the current date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);


updateDisplay();
}


private void updateDisplay() {
 mDateDisplay.setText(
new StringBuilder()

.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append(" "));
}



private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {

public void onDateSet(DatePicker view, int year,
  int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};



 protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
mDateSetListener,
mYear, mMonth, mDay);
}
return null;
}

}


On Aug 9, 10:44 am, nageswara rao rajana 
wrote:
> Hi,
>
>      I want to set default date for date picker. Can any one please help me.
>
>  Thanking you,
>  Nagu.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android Date Picker

2008-12-08 Thread Mark Murphy

Muthu Kumar K. wrote:
> Can any you give me some example, because i am new to Android.

ApiDemos/src/com/example/android/apis/view/DateWidgets1.java

That example of DatePickerDialog can be found in the samples/ directory 
of your SDK installation.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Date Picker

2008-12-08 Thread Muthu Kumar K.

hi,
Can any you give me some example, because i am new to Android.
Thanks,
Muthu Kumar K.

On Dec 8, 5:38 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
> Muthu Kumar K. wrote:
> > can any one help me how do i get the date form DatePicker?
>
> It should be provided to the DatePicker.OnDateChangedListener you gave
> the picker.
>
> Or, if you are using DatePickerDialog, it should be provided to the
> DatePickerDialog.OnDateSetListener you gave the dialog.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
>
> Android Training on the Ranch! -- Mar 16-20, 
> 2009http://www.bignerdranch.com/schedule.shtml
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Date Picker

2008-12-08 Thread Mark Murphy

Muthu Kumar K. wrote:
> can any one help me how do i get the date form DatePicker?

It should be provided to the DatePicker.OnDateChangedListener you gave 
the picker.

Or, if you are using DatePickerDialog, it should be provided to the 
DatePickerDialog.OnDateSetListener you gave the dialog.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---