problems with date picker in an android app - java

hi i my app i have placed two edit text boxes, when i touch on it the date picker dialog box gets appeared.
Now the problem is when i touch the first edit box the dialog opens and after setting it displays at the EditText1. Then when i touch the second edit box the dialog opens and after setting some other date, it is not displayed in EditText2, instead it is show in the EditText1 and the former date gets changed
I want the dates to be displayed in respective boxes.
The following is my code
{
et1 =(EditText)findViewById(R.id.widget29);
et1.setHint("DOB");
et2 =(EditText)findViewById(R.id.widget32);
et2.setHint("DOF");
et1.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
showDialog(DATE_DIALOG_ID);
}
});
et2.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
showDialog(DATE_DIALOG_ID);
}
});
// 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);
}
private void updateDisplay()
{
this.et1.setText(
new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append("-"));
}
private void updateDisplay1()
{
this.et2.setText(
new StringBuilder()
// Month is 0 based so add 1
.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();
}
};
private DatePickerDialog.OnDateSetListener mDateSetListener1 = new DatePickerDialog.OnDateSetListener()
{
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay1();
}
};
#Override
protected Dialog onCreateDialog(int id)
{
switch (id)
{
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
}
return null;
}
}
the following are some more problems i am facing here,
Whenever i touch the edit text box the keyboard also gets opened how to hide the keyboard
in the EditText box i want the order to be viewed as Year/Month/Date
Is there any way to change the date picker dialog box as the below figure
please help me in this

Check this code..
public class Main extends Activity {
EditText et1,et2;
static final int DATE_DIALOG_ID = 0;
static final int DATE_DIALOG_ID1 = 1;
private int mYear;
private int mMonth;
private int mDay;
private int mYear1;
private int mMonth1;
private int mDay1;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1=(EditText)findViewById(R.id.EditText01);
et2=(EditText)findViewById(R.id.EditText02);
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
et1.setText("month/year");
et2.setText("month/year");
et1.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
showDialog(DATE_DIALOG_ID);
return false;
}
});
et2.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
showDialog(DATE_DIALOG_ID1);
return false;
}
});
}
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
mDay);
case DATE_DIALOG_ID1:
return new DatePickerDialog(this, mDateSetListener1, mYear1, mMonth1,
mDay1);
}
return null;
}
// updates the date in the TextView
private void updateDisplay() {
et1.setText(new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-").append(mYear));
}
private void updateDisplay1() {
et2.setText(new StringBuilder()
// Month is 0 based so add 1
.append(mMonth1 + 1).append("-").append(mYear1));
}
// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
private DatePickerDialog.OnDateSetListener mDateSetListener1 = new DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker view, int year1, int monthOfYear1,
int dayOfMonth1) {
// TODO Auto-generated method stub
mYear1 = year1;
mMonth1 = monthOfYear1;
mDay1 = dayOfMonth1;
updateDisplay1();
}
};
}

You're setting the same id for both show dialog methods...
et1.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
showDialog(DATE_DIALOG_ID);
}
});
et2.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
showDialog(DATE_DIALOG_ID);
}
});
...and your switch/case block only has one 'case'....
switch (id)
{
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
}
As for the other issues, split them into separate questions.

Related

showDialog not displayed Android

Inside an Activity, I am calling different fragments , I want the user to be able to change the date by clicking on a textView that displays the current date, the showDialog does not want to be displayed.
dateView.setOnClickListener(new View.OnClickListener() {
#SuppressWarnings("deprecation")
public void onClick(View v) {
getActivity().showDialog(999);
}
});
Android Studio tells me that CreateDialog is never used.
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
if (id == 999) {
return new DatePickerDialog(getContext(),
myDateListener, year, month, day);
}
return null;
}
Full code:
public class Fragment5 extends android.support.v4.app.Fragment {
private DatePicker datePicker;
private Calendar calendar;
private TextView dateView;
TimePicker timePicker2;
private int year, month, day;
public Fragment5() {
}
#RequiresApi(api = Build.VERSION_CODES.N)
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_fragment5, container, false);
dateView = (TextView) rootView.findViewById(R.id.textView3);
calendar = Calendar.getInstance();
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH);
day = calendar.get(Calendar.DAY_OF_MONTH);
showDate(year, month+1, day);
dateView.setOnClickListener(new View.OnClickListener() {
#SuppressWarnings("deprecation")
public void onClick(View v) {
getActivity().showDialog(999);
}
});
return rootView;
}
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
if (id == 999) {
return new DatePickerDialog(getContext(),
myDateListener, year, month, day);
}
return null;
}
private DatePickerDialog.OnDateSetListener myDateListener = new
DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker arg0,
int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
// arg1 = year
// arg2 = month
// arg3 = day
showDate(arg1, arg2+1, arg3);
}
};
private void showDate(int year, int month, int day) {
dateView.setText(new StringBuilder().append(day).append("/")
.append(month).append("/").append(year));
}
}
MainActivity
public class MainActivity extends AppCompatActivity {
public static Bundle myBundl = new Bundle();
private List<ItemSlideMenu> listSliding;
private SlidingMenuAdapter3 adapter;
private Calendar calendar;
private TextView dateView;
TimePicker timePicker2;
final Context context = this ;
private int year, month, day;
private ListView listViewSliding;
private DrawerLayout drawerLayout;
private ActionBarDrawerToggle actionBarDrawerToggle;
String name1;
#RequiresApi(api = Build.VERSION_CODES.N)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
calendar = Calendar.getInstance();
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH);
day = calendar.get(Calendar.DAY_OF_MONTH);
showDate(year, month+1, day);
//Init component
listViewSliding = (ListView) findViewById(R.id.lv_sliding_menu);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
listSliding = new ArrayList<>();
//Add item for sliding list
listSliding.add(new ItemSlideMenu(R.drawable.home_96,"Accueil" ));
listSliding.add(new ItemSlideMenu(R.drawable.cocktail,"Organiser une Sortie"));
listSliding.add(new ItemSlideMenu(R.drawable.geo,"Autour de moi"));
listSliding.add(new ItemSlideMenu(R.drawable.ami,"Liste d'amis" ));
listSliding.add(new ItemSlideMenu(R.drawable.message,"Contact"));
listSliding.add(new ItemSlideMenu(R.drawable.information,"Credits"));
adapter = new SlidingMenuAdapter3(this, listSliding);
listViewSliding.setAdapter(adapter);
//Display icon to open/ close sliding list
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Set title
setTitle(listSliding.get(0).getTitle());
//item selected
listViewSliding.setItemChecked(0, true);
//Close menu
drawerLayout.closeDrawer(listViewSliding);
//Display fragment 1 when start
replaceFragment(0);
//Hanlde on item click
listViewSliding.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Set title
setTitle(listSliding.get(position).getTitle());
//item selected
listViewSliding.setItemChecked(position, true);
if (position==2){
Intent i2 = new Intent(getApplicationContext(), MapsActivity.class);
startActivity(i2);
} else
{//Replace fragment
replaceFragment(position);
}//Close menu
drawerLayout.closeDrawer(listViewSliding);
}
});
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_opened, R.string.drawer_closed){
#Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
invalidateOptionsMenu();
}
#Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
invalidateOptionsMenu();
}
};
drawerLayout.setDrawerListener(actionBarDrawerToggle);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if(actionBarDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
actionBarDrawerToggle.syncState();
}
//Create method replace fragment
private void replaceFragment(int pos) {
android.support.v4.app.Fragment fragment = null;
switch (pos) {
case 0:
fragment = new Fragment1();
break;
case 1:
fragment = new Fragment2();
break;
case 2:
fragment = new Fragment3();
break;
case 3 :
fragment = new Fragment4();
break;
}
if(null!=fragment) {
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.main_content,fragment);
transaction.addToBackStack(null);
transaction.commit();
}
}
#SuppressWarnings("deprecation")
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
if (id == 999) {
return new DatePickerDialog(this,
myDateListener, year, month, day);
}
else if (id ==98) {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Title...");
// set the custom dialog components - text, image and button
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
dialogButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment6 fragment = null;
fragment = new Fragment6();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.contact, fragment);
transaction.addToBackStack(null);
transaction.commit();
dialog.dismiss();
}
});
dialog.show();
// if button is clicked, close the custom dialog
}
return null;
}
private DatePickerDialog.OnDateSetListener myDateListener = new
DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker arg0,
int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
// arg1 = year
// arg2 = month
// arg3 = day
showDate(arg1, arg2+1, arg3);
}
};
private void showDate(int year, int month, int day) {
StringBuilder abbes = new StringBuilder().append(day).append("/")
.append(month).append("/").append(year);
Bundle bundle = new Bundle();
bundle.putString("edttext", String.valueOf(abbes));
// set Fragmentclass Arguments
Fragment5 fragobj = new Fragment5();
fragobj.setArguments(bundle);
}
}
Since,
Callback for creating dialogs that are managed (saved and restored) for you by the Activity.
Implement this method in Activityinstead of Fragment
#Override
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
if (id == 999) {
return new DatePickerDialog(getContext(),
myDateListener, year, month, day);
}
return null;
}
Call Fragment like this;
private void showDate(int year, int month, int day) {
StringBuilder abbes = new StringBuilder().append(day).append("/")
.append(month).append("/").append(year);
if(fragment instanceof Fragment4){
((Fragemnt4)fragment).dateView.setText(""+abbes);
}
}
Make dateView public
showDialog() is deprecated. Replace this code
public class Fragment5 extends android.support.v4.app.Fragment {
private DatePicker datePicker;
private Calendar calendar;
private TextView dateView;
TimePicker timePicker2;
private int year, month, day;
DialogFragment dateFragment;
public Fragment5() {
}
#RequiresApi(api = Build.VERSION_CODES.N)
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_fragment5, container, false);
dateView = (TextView) rootView.findViewById(R.id.textView3);
calendar = Calendar.getInstance();
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH);
day = calendar.get(Calendar.DAY_OF_MONTH);
showDate(year, month+1, day);
dateView.setOnClickListener(new View.OnClickListener() {
#SuppressWarnings("deprecation")
public void onClick(View v) {
dateFragment = new DatePickerFragment();
dateFragment.show(getFragmentManager(), "datePicker");
}
});
return rootView;
}
private void showDate(int year, int month, int day) {
dateView.setText(new StringBuilder().append(day).append("/")
.append(month).append("/").append(year));
}
class DatePickerFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
showDate(year,month,day);
}
} }
What exactly showDialog (int id) method does is show a dialog managed by activity. A call to onCreateDialog(int, Bundle) will be made with the same id the first time this is called for a given id. From thereafter, the dialog will be automatically saved and restored.
You must write your onCreateDialog method in Activity as said by #Burhanuddin Rashid but that could cause complexity in data transition between Activity and Fragment.
Further,
void showDialog (int id)
This method was deprecated in API level 13.
Use the new DialogFragment class with FragmentManager instead; this is also available on older platforms through the Android compatibility package.
PS,
I recommend you to use a DialogFragment
For more info check out this official documentation

LayoutInflater with DatePicker Dialog

I am trying to set an editText with a DatePickerDialog inside a .setOnClickListener. where, when the user clicks on the editText the DatePickerDialog will appear and then after the user selects the desirable date it will set it on the editText... something like this : Android:DatePickerDialog on EditText Click Event
and here is my code mycode
Any ideas how to do that?
I tried the above example and many more but nothing seems to work inside the .SetOnClickListener
Use this code:
public class MainActivity extends AppCompatActivity {
EditText text;
private int year,currentYear;
private int month,currentMonth;
private int day,currentDay;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (EditText)findViewById(R.id.edit);
// Get current date by calender
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
text.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
#Override
public void onDateSet(DatePicker datePicker, int mYear, int mMonth, int mDay) {
currentDay = mDay;
currentMonth = mMonth+1;
currentYear = mYear;
text.setText(mDay+"-"+(mMonth+1)+"-"+mYear);
}
},year,month,day).show();
}
});
}
}
I have store the user selected year, month, day in currentYear,currentMonth,currentDay respectively.

helpme for TimePickerDialog and date now

I am using a button which shows the hour and minute of the team with this method
private void obtenerFechaActual() {
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
}
btnSelectTime.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Show the TimePickerDialog
obtenerFechaActual();
showDialog(TIME_DIALOG_ID);
}
});
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case TIME_DIALOG_ID:
return new TimePickerDialog(this,
mTimeSetListener, mHour, mMinute, false);
}
return null;
}
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int min) {
hour = hourOfDay;
minute = min;
btnSelectTime.setText("Time selected :"+hour+"-"+minute);
}
};
It does well, but every time I press the button,it keeps the minutes and the date of the first click of the button. The idea is that every time you click the button, it displays the current time and date.
add this method:
#Override
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case TIME_DIALOG_ID:
((TimePickerDialog) dialog).updateTime(mHour, mMinute);
break;
case DATE_DIALOG_ID:
((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
break;
}
}

Android datepicker. How i can hide day field?

I want to show month and year only, how i can do it? I have been try to search some solution but for me it's not work. May be i need to create my custom date picker dialog ? Here is my code:
DatePickerDialog.OnDateSetListener d = new DatePickerDialog.OnDateSetListener()
{
public int Syear;
public int Smonth;
#Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH,monthOfYear);
#Override
public void onScrollStateChanged(AbsListView view,
int scrollState) {
// Auto-generated method stub
}
});
}
};
public void setDate()
{
new DatePickerDialog(InboxActivity.this,d,calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)).show();
}
#Override
public void onClick(View v)
{
this.setDate();
}
May be this may work... not a tested solution though
import java.util.date;
SimpleDateFormat dateformat=new SimpleDateFormat("MM/yyyy");
dateformat.format(new Date());

Android DatePicker showing Full Screen on Initialization

I have followed this tutorial to integrate a datepicker into my app, I have tailored the original to suit my needs and managed to get it working. Unfortunately the author doesn't go too much into the concepts of actually using the DatePicker dialog.
As a result, a full screen calendar is shown when the app is launched, whereas I am simply trying to pull the day, month and year when the button 'Pick Date' is clicked, what do I need to remove?
Code here:
public class MainActivity extends Activity implements OnClickListener,
OnCheckedChangeListener {
TabHost th;
Button changeDate;
TextView displayDate;
public static final int dDialogId = 1;
// date and time
private int mYear;
private int mMonth;
private int mDay;
#Override
protected void onCreate(Bundle savedInstanceState) {
// Set activity to full screen!!
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
th = (TabHost) findViewById(R.id.tabhost);
th.setup();
TabSpec specs = th.newTabSpec("tag1");
// one tab
specs.setContent(R.id.tab1);
// what appears on actual tab
specs.setIndicator("Tools");
th.addTab(specs);
specs = th.newTabSpec("tag2");
// one tab
specs.setContent(R.id.tab2);
// what appears on actual tab
specs.setIndicator("Calorie Calculator");
th.addTab(specs);
specs = th.newTabSpec("tag3");
// one tab
specs.setContent(R.id.tab3);
// what appears on actual tab
specs.setIndicator("Your Stats!");
th.addTab(specs);
initializeVariables();
}
private void initializeVariables() {
mapARun = (Button) findViewById(R.id.btnMapARun);
weightConverter = (Button) findViewById(R.id.btnWeightConverter);
changeDate = (Button) findViewById(R.id.btnChangeDate);
displayDate = (TextView) findViewById(R.id.tvDisplayDate);
changeDate.setOnClickListener(this);
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
updateDisplay();
}
#Override
#Deprecated
protected void onPrepareDialog(int id, Dialog dialog) {
// TODO Auto-generated method stub
super.onPrepareDialog(id, dialog);
((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
}
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();
}
};
private void updateDisplay() {
displayDate.setText(new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-").append(mDay).append("-")
.append(mYear));
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnChangeDate:
DatePickerDialog DPD = new DatePickerDialog(this,
mDateSetListener, mYear, mMonth, mDay);
DPD.show();
break;
}
}
}
}
Apologies if you hit syntax errors when the codei s run, I cut out a lot of the other, unrelated functions,
Is there another way to just show the datepicker when the dialog is called?
Create yout main category with just the button.
Make the button call another activity with your code.
You'll get a screen with a button that calls another screen with a fullscreen datepicker.
Make the DatePicker Activity end itself when date is selected.
Make sure you are calling the activity with startActivityForResult and end it with finishWithResult.

Categories