Skip to main content

Time Picker Dialog Box in android

Android Time picker are used a lot in android apps.

Android Button Click And Open TatePickerDialog Box

In your build.gradle add latest appcompat library, at the time 24.2.1

dependencies {  
    compile 'com.android.support:appcompat-v7:X.X.X' 
    // where X.X.X version
}

  1. activity_main.xml

  • Set On TextView Click Listener 
  • <TextView  
    android:id="@+id/tvTime"
    android:layout_width="match_parent"
    android:layout_height="44dp"   android:layout_alignParentStart="true"   android:layout_alignParentLeft="true"   android:layout_alignParentTop="true"   android:layout_marginStart="0dp"   android:layout_marginLeft="0dp"   android:layout_marginTop="38dp"   android:text="DD-MM-YYYYY"  
    android:textSize="24sp" /> 
  • After Select the date and  set the textview
==>MainActivity.java

  • Find the id of TextView and and store TextView Object
  • TextView tvTime = findViewById(R.id.tvTime);

  1. tvTime.setOnClickListener(new View.OnClickListener() {
  2.     @Override
  3.     public void onClick(View view) {
  4.     // Get Current Time
  5.     final Calendar c = Calendar.getInstance();
  6.     mHour = c.get(Calendar.HOUR_OF_DAY);
  7.     mMinute = c.get(Calendar.MINUTE);
  8.     // Launch Time Picker Dialog
  9.     TimePickerDialog timePickerDialog = new TimePickerDialog(context,
  10.         new TimePickerDialog.OnTimeSetListener() {
  11.             @Override
  12.             public void onTimeSet(TimePicker view, int hourOfDay,int minute) {
  13.                 tvTime.setText(hourOfDay + ":" + minute);
  14.             }
  15.         }, mHour, mMinute, false);
  16.     timePickerDialog.show();
  17.     }
  18. });

Comments

Popular posts from this blog

Laravel Artisan Command

1) Clear Cache facade value: php artisan cache:clear 2) Clear Route cache: php artisan route:cache 3) Clear View cache: php artisan view:clear 4) Clear Config cache: php artisan config:cache 5) Key Generate php artisan key:generate

DatePickerDialog Box

Android Date Time picker are used a lot in android apps. Android Button Click And Open DatePickerDialog Box In your build.gradle add latest appcompat library, at the time 24.2.1 dependencies { compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version } activity_main.xml Set On TextView Click Listener   < TextView android :id= "@+id/tvDate" android :layout_width= "match_parent" android :layout_height= "44dp" android :layout_alignParentStart= "true" android :layout_alignParentLeft= "true" android :layout_alignParentTop= "true" android :layout_marginStart= "0dp" android :layout_marginLeft= "0dp" android :layout_marginTop= "38dp" android :text= "DD-MM-YYYYY" android :textSize= "24sp" /> After Select the date and and set the textview ==>MainActivity.java Find...

laravel debugbar

This is a package to integrate  PHP Debug Bar  with Laravel 5. It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel. It bootstraps some Collectors to work with Laravel and implements a couple custom DataCollectors, specific for Laravel. It is configured to display Redirects and (jQuery) Ajax Requests. (Shown in a dropdown) Read  the documentation  for more configuration options. https://github.com/barryvdh/laravel-debugbar