logo
down
shadow

Android: use a datepicker and timepicker from within a Dialog


Android: use a datepicker and timepicker from within a Dialog

By : MChavan
Date : October 21 2020, 11:12 AM
I wish did fix the issue. I am facing a problem I do not know how to solve. , Here's what I have that works:
code :


Share : facebook icon twitter icon
Using DatePicker and TimePicker dialog boxes - Android Java in Eclipse

Using DatePicker and TimePicker dialog boxes - Android Java in Eclipse


By : RSD
Date : March 29 2020, 07:55 AM
I hope this helps you . I have no errors on the code, but when I launch I get a fatal error in my main XML page that says, , Check this Code: Its working fine now.
code :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imgCabin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="strCabin"
        android:src="@drawable/ic_launcher" />

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <TableRow>

            <TextView
                android:id="@+id/txtTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#666FFF"
                android:text="strTitle"
                android:textSize="40sp"
                android:typeface="serif" />
        </TableRow>

        <TableRow>

            <TextView
                android:id="@+id/txtDesc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="strDesc"
                />
        </TableRow>

        <TableRow>

            <RadioGroup
                android:id="@+id/radio"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:contentDescription="strRad" >

                <RadioButton
                    android:id="@+id/radCabin1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginLeft="250dp"
                    android:checked="true"
                    android:text="strCabinOne"
                    android:textSize="25sp" />

                <RadioButton
                    android:id="@+id/radCabin2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="250dp"
                    android:text="strCabinTwo"
                    android:textSize="25sp" />
            </RadioGroup>
        </TableRow>

        <TableRow>

            <Button
                android:id="@+id/btnDate"
                android:layout_width="50dp"
                android:padding="20sp"
                android:text="strDate"
                android:textSize="25sp" />
        </TableRow>

        <TableRow>

            <Button
                android:id="@+id/btnTime"
                android:layout_width="50dp"
                android:padding="20sp"
                android:text="strTime"
                android:textSize="25sp" />
        </TableRow>

        <TableRow>

            <TextView
                android:id="@+id/txtDate"
                android:layout_gravity="center"
                android:padding="20dp"
                android:textSize="25sp" />
        </TableRow>

        <TableRow>

            <TextView
                android:id="@+id/txtTime"
                android:layout_gravity="center"
                android:padding="20dp"
                android:textSize="25sp" />
        </TableRow>
    </TableLayout>

</LinearLayout>
public class Main extends Activity {

    private int currentYear;
    private int currentMonth;
    private int currentDay;
    static final int DATE_DIALOG_ID = 0;
    static final int TIME_DIALOG_ID = 1;
    int hour;
    int minute;
    String cabin1 = "The Wooden Castle";
    String cabin2 = "Cozy Little Spot";
    private Button btDate;
    private Button btTime;
    private TextView timeDisplay;
    private TextView dateDisplay;
    private RadioButton c1;
    private RadioButton c2;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final Calendar c = Calendar.getInstance();
        currentYear = c.get(Calendar.YEAR);
        currentMonth = c.get(Calendar.MONTH);
        currentDay = c.get(Calendar.DAY_OF_MONTH);
        hour = c.get(Calendar.HOUR_OF_DAY);
        minute = c.get(Calendar.MINUTE);

        timeDisplay = (TextView) findViewById(R.id.txtTime);
        dateDisplay = (TextView) findViewById(R.id.txtDate);
        btDate = (Button) findViewById(R.id.btnDate);
        btTime = (Button) findViewById(R.id.btnTime);
        c1 = (RadioButton) findViewById(R.id.radCabin1);
        c2 = (RadioButton) findViewById(R.id.radCabin2);
        btDate.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                showDialog(DATE_DIALOG_ID);
            }
        });
        btTime.setOnClickListener(new View.OnClickListener() {

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

    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DATE_DIALOG_ID:
            return new DatePickerDialog(this, reservationDate, currentYear,
                    currentMonth, currentDay);
        case TIME_DIALOG_ID:
            return new TimePickerDialog(this, timeDate, hour, minute, false);
        }
        return null;
    }

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

        public void onDateSet(DatePicker view, int year, int month, int day) {
            if (c1.isChecked()) {

                dateDisplay.setText("Your rental time is set for "
                        + (month + 1) + "-" + day + "-" + year + " to "
                        + (month + 1) + "-" + (day + 3) + "-" + year + " in "
                        + cabin1 + ".");
            }
            if (c2.isChecked()) {
                dateDisplay.setText("Your rental time is set for "
                        + (month + 1) + "-" + day + "-" + year + " to "
                        + (month + 1) + "-" + (day + 3) + "-" + year + " in "
                        + cabin2 + ".");
            }
        }

    };

    private TimePickerDialog.OnTimeSetListener timeDate = new TimePickerDialog.OnTimeSetListener() {

        public void onTimeSet(TimePicker view, int hours, int minutes) {
            timeDisplay.setText("Your arrival time will be at " + hours + ":"
                    + minutes + ".");
        }
    };

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
Datepicker and TimePicker in a form, datepicker works fine but timePicker doesn't drop down in field

Datepicker and TimePicker in a form, datepicker works fine but timePicker doesn't drop down in field


By : Jony Fernnado Schulz
Date : March 29 2020, 07:55 AM
To fix the issue you can do Based on your comment above, I would guess your code is not executing because you have not included jquery.timePicker.js in your code. Download the file and include it like this:
code :
 <script src="path/to/your/js/file/jquery.timePicker.js"></script>
I want to use digital datepicker dialog and timepicker dialog

I want to use digital datepicker dialog and timepicker dialog


By : Carlos Pérez Araujo
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , its very simple and i got my code working , i need to add theme and its done
code :
case R.id.linearDate: {

                DatePickerDialog dp = new DatePickerDialog(this,android.R.style.Theme_Holo_Light_Dialog,new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                        mDatetext.setText(dayOfMonth+"-"+monthOfYear+"-"+year);

                    }
                },year,month,day);
                dp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dp.show();
            }break;

            case R.id.linearTime: {

                TimePickerDialog Tp = new TimePickerDialog(this,android.R.style.Theme_Holo_Light_Dialog, new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        mTimetext.setText(hourOfDay+ ":" +minute);

                    }
                },hour,min,false);
                Tp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                Tp.show();
            }break;
Android: timepicker and datepicker in the same dialog box

Android: timepicker and datepicker in the same dialog box


By : basicline
Date : March 29 2020, 07:55 AM
To fix this issue You can find a DateTimePicker implementation here:
http://code.google.com/p/datetimepicker/
How to change the default color of DatePicker and TimePicker dialog in Android?

How to change the default color of DatePicker and TimePicker dialog in Android?


By : booba figuig
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The best way to change the picker dialog is by adding custom style to it.
Related Posts Related Posts :
  • Unexpected token in JSON at position 1024 react native
  • How to make android.net.Uri encode & between query parameters to %26
  • How to simply save image to photo gallery
  • SQLite query to select one row and return it with 2 next rows
  • APK which I developed used to work fine earlier, but suddenly stopped working with "App not installed" error
  • Time Picker Fragments Differentiation
  • ExoPlayer Cant Play some audio streams
  • Start Activity for Result Request Code in Library Project
  • Getting a string value from the strings.xml resource file and set it in an interface class
  • Flutter, sign with both debug keys and release keys on Android
  • will an android service run code from the Xamarin Forms Project even when the app is closed?
  • Change boolean values on listviewitems in firebase
  • Android Studio 3.2.1: mixing versions can lead to runtime crashes when connect firebase
  • FCM migration without losing the old token
  • Change reported Version Number in Fabric Crashlytics
  • lateinit property mMap has not been initialized
  • Android - PWA does not open in standalone mode with service worker
  • Does LeakCanary has callback?
  • How to disable back button after splash screen in React Native
  • Assets Folder Not Including HTML Files In NativeScript Android Build
  • Dagger: What if I *WANT* a new instance every time?
  • How to get mailto working on android chrome?
  • SSO web login in android app with customtabs
  • how to make specific button side curved
  • remove item onlongclick from listview
  • header image alignment coming wrongly in NavigationView android
  • How to add many spaces after the text in TextView
  • how to set "Back Button" , closing activies except main activity in android?
  • Unable to run emulator on Android Studio || Windows 10
  • How can I achieve this requirement using Rx Java
  • How to tilt a Node(or TransformableNode)object downwards in Sceneform(Ar Core)?
  • When to use RTL and LTR?
  • How to create a tab view (category) similar to instagram's explore tab
  • Glide, RecyclerView: Glide returns the same picture over and over again even with different data inputs
  • how to stop open activity while splash screen killed
  • Changing the Color of the Dynamically loaded Buttons onclick
  • Listview: Add arrows as dividers
  • Show confirmation on back/up in Fragment with Navigation Architecture Component
  • How to find the corresponding maven artifact/gradle module of an Android class from the API Docs?
  • ZXing 3.6.0 in portrait mode?
  • Can't use Subversion command line client: svn The path to the Subversion executable is probably wrong android
  • how to set spinner list value first position showing empty
  • When using PersistableBundle in onCreate, it shows me a blank page
  • Failed to resolve Bintray dependency
  • jacoco code coverage not working for Android applications
  • How to change the color of the Android scroll bumper
  • Why run Handler in main Looper thread
  • Android Studio combined chart crashes
  • Setting suggested width and height to a custom view in android
  • How to set input type and format in EditText using kotlin?
  • how to define Android Oncreate optionmenu
  • Exception on orientation change from two-pane mode to one-pane mode
  • How to access members of nested struct and assign them the values read from device tree?
  • How to measure upload progress of a huge String with Retrofit 2?
  • Runtime app localization doesn't work with app bundles
  • How create View and Putting TextView inside it in kotlin
  • how to integrate app action using actions.xml?
  • ConstraintLayout - center TextView in the root but don't override Button
  • Android Studio Text not conforming to layout_margin when I run App on Emulator
  • verifyReleaseResources apk release - react native
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org