Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following code will help you to get both,</p> <p>date_time_picker.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_height="match_parent"&gt; &lt;DatePicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/datePicker"&gt;&lt;/DatePicker&gt; &lt;TimePicker android:id="@+id/timePicker" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/TimePicker&gt; &lt;TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center"&gt; &lt;Button android:id="@+id/btnSetDateTime" android:layout_height="wrap_content" android:text="Set" android:layout_width="120dp"&gt;&lt;/Button&gt; &lt;/TableRow&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p>use the following java code:</p> <pre><code>ScrollView DTPicker = (ScrollView) View.inflate(context, R.layout.date_time_picker, null); Button btnSet = (Button) DTPicker.findViewById(R.id.btnSetDateTime); DatePicker dp = (DatePicker) DTPicker.findViewById(R.id.datePicker); TimePicker tp = (TimePicker) DTPicker.findViewById(R.id.timePicker); btnSet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String strDateTime = dp.getYear() + "-" + (dp.getMonth() + 1) + "-" + dp.getDayOfMonth() + " " + tp.getCurrentHour() + ":" + tp.getCurrentMinute(); }}); alert = new AlertDialog.Builder(context).create(); alert.setTitle("Reminder"); alert.setView(DTPicker); alert.show(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload