Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:26:55+00:00 2026-05-28T05:26:55+00:00

I’m trying to make work this example from http://developer.android.com/resources/tutorials/views/hello-timepicker.html , no errors while compiling

  • 0

I’m trying to make work this example from http://developer.android.com/resources/tutorials/views/hello-timepicker.html ,
no errors while compiling – but when I press button – nothing happens. Complete silent. Why? Btw – I tried to put Log.d() in button click event and it works, but still no popup with timepicker.

Main.xml used “As is” from example

import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

public class TestastestasActivity extends Activity {

      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();
                    }
                };

    // updates the date we display in the TextView
    private void updateDisplay() {
        mDateDisplay.setText(
            new StringBuilder()
                    // Month is 0 based so add 1
                    .append(mMonth + 1).append("-")
                    .append(mDay).append("-")
                    .append(mYear).append(" "));
    }

    /** Called when the activity is first created. */
     private TextView mDateDisplay;
        private Button mPickDate;

        private int mYear;
        private int mMonth;
        private int mDay;

        static final int DATE_DIALOG_ID = 0;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            // capture our View elements
            mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
            mPickDate = (Button) findViewById(R.id.pickDate);

            // add a click listener to the button
            mPickDate.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Log.d ("Debug", "YO MAN");
                    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);

            // display the current date
            updateDisplay();
        }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:26:56+00:00Added an answer on May 28, 2026 at 5:26 am

    main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView android:text="@string/date_text" 
        android:id="@+id/TextView01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="26px" 
        android:typeface="sans"></TextView>
    <Button android:text="@string/date_button" 
        android:id="@+id/Button01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"></Button>
    
    <TextView android:text="@string/time_text" 
        android:id="@+id/TextView02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:textSize="26px" 
        android:typeface="sans"></TextView>
    <Button android:text="@string/time_button" 
        android:id="@+id/Button02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"></Button>
    </LinearLayout>
    

    datepickerlayout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
    <DatePicker 
        android:id="@+id/DatePicker01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        ></DatePicker>
    </LinearLayout>
    

    PickerViewSample.java

    package com.sai.samples.views;
    
    import java.util.Calendar;
    
    import android.app.Activity;
    import android.app.DatePickerDialog;
    import android.app.Dialog;
    import android.app.TimePickerDialog;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.DatePicker;
    import android.widget.TextView;
    import android.widget.TimePicker;
    
    public class PickerViewSample extends Activity {
    
        static final int DATE_DIALOG_ID = 1;
        static final int TIME_DIALOG_ID = 2;
        private TextView dateDisplay;
        private Button pickDate;
        private int year, month, day;
        private TextView timeDisplay;
        private Button pickTime;
        private int hours, min;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            dateDisplay = (TextView)findViewById(R.id.TextView01);
            pickDate = (Button)findViewById(R.id.Button01);
    
            pickDate.setOnClickListener( new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    showDialog(DATE_DIALOG_ID);
                }
    
            });
    
            final Calendar cal = Calendar.getInstance();
            year = cal.get(Calendar.YEAR);
            month = cal.get(Calendar.MONTH);
            day = cal.get(Calendar.DAY_OF_MONTH);
    
            updateDate();
    
            timeDisplay = (TextView)findViewById(R.id.TextView02);
            pickTime = (Button)findViewById(R.id.Button02);
    
            pickTime.setOnClickListener( new OnClickListener () {
    
                @Override
                public void onClick(View v) {
                    showDialog(TIME_DIALOG_ID);
    
                }
    
            });
    
            hours = cal.get(Calendar.HOUR);
            min = cal.get(Calendar.MINUTE);
    
            updateTime();
        }
    
        private void updateTime() {
            timeDisplay.setText(new StringBuilder().append(hours).append(':')
                    .append(min));
    
        }
    
        private void updateDate() {
            dateDisplay.setText(new StringBuilder().append(day).append('-')
                    .append(month + 1).append('-').append(year));
    
        }
    
        private DatePickerDialog.OnDateSetListener dateListener = 
            new DatePickerDialog.OnDateSetListener() {
    
                @Override
                public void onDateSet(DatePicker view, int yr, int monthOfYear,
                        int dayOfMonth) {
                    year = yr;
                    month = monthOfYear;
                    day = dayOfMonth;
                    updateDate();
                }
        };
    
        private TimePickerDialog.OnTimeSetListener timeListener = 
            new TimePickerDialog.OnTimeSetListener() {
    
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    hours = hourOfDay;
                    min = minute;
                    updateTime();
                }
    
        };
        protected Dialog onCreateDialog(int id){
            switch(id) {
            case DATE_DIALOG_ID:
                return new DatePickerDialog(this, dateListener, year, month, day);
            case TIME_DIALOG_ID:
                return new TimePickerDialog(this, timeListener, hours, min, false);
            }
            return null;
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.