DatePickerDialog with spinner mode themes


It doesn't work on Nougat, Android 7.0+ 
To create a DatePickerDialog in Sketchware android project follow the steps given below.

1. In VIEW area of your sketchware android project, insert a LinearH and inside it insert a TextView textview1, and a Button button1.

2. Add a More Block 'extra'.


3. To define the block extra, insert an add source directly block and put following code in it:
}
public void showDatePickerDialog(View v) {
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(), "datePicker");
}
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
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);
return new DatePickerDialog(getActivity(), android.R.style.Theme_Holo_Dialog, this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
int mon = month +1;
String date = day + "/" + mon + "/" + year;
textview1.setText(date);

}

For light theme replace
android.R.style.Theme_Holo_Dialog 
with
android.R.style.Theme_Holo_Light_Dialog
in the code above.


4. Add a new event button1 onClick. In the event insert an add source directly block and put following code:
showDatePickerDialog(button1);

5. Save and run the project. Now on clicking the Button, DatePickerDialog will appear.

Comments

  1. Hi. I see you just posted this. Can you tell me how to make a button play a short sound clip when you tap it?

    ReplyDelete
    Replies
    1. Just add a media player component and your sound you want so the button you want on click to make sound to tap on button on click and add a media player on create block followed by media player start block

      Delete
  2. I want solution of this for Nougat and + versions.
    Please also make an tutorials for this.
    Million of people are searching for this solution.
    Your website will ranking fast if u make an solution tutorial for this problem.

    ReplyDelete
  3. Como crear una aplicación de sticker para whatsapp desde sketchware

    ReplyDelete
  4. How to create a label application for whatsapp from sketchware

    ReplyDelete
  5. Merci beaucoup mais je me suis toujours demandé comment faire une application de story , parce que moi j'aime bien les story et je veux crée une application qui permet de faire les Story

    ReplyDelete
  6. How to change admob ad unit id and test id,if I changed the device by saving project file backup..
    Project is restored,but test id is old one so ad not showing..

    ReplyDelete
  7. Hello friend could you tell me a code for me to get the ip of the network I'm connected?

    ReplyDelete
  8. Sir I'm having a problem regarding my API sir please help me sir

    ReplyDelete
  9. publish your app on google playstore for $5 every month 07035768635(whatsapp only)

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware