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