Change UI of Date Picker for Android TV app - android

I'm writing an android tv app with lean-back and I want to use android standard date picker and I want to make this like this pic
(eg: Made year part bigger when the user is selecting year and so on)
How can I achieve this?

You cannot use the standard date picker in Android TV apps because it was not designed for navigation using D-Pad. However, you can create your own widgets for day, month and year selection. You can simply use VerticalGridView to create them. For instance, you can do something similar to this for days:
<androidx.leanback.widget.VerticalGridView
android:id="#+id/vgv_days"
android:background="#color/transparent"
android:layout_marginEnd="10dp"
android:layout_width="40dp"
android:layout_height="35dp" />
customArrayObjectAdapterDays = new CustomArrayObjectAdapter(new DatePartPresenter(getContext()));
for (int i = 1; i < 31; i++) {
customArrayObjectAdapterDays.add(i);
}
vgvDays = (VerticalGridView) view.findViewById(R.id.vgv_days);
vgvDays.setNumColumns(1);
vgvDays.setAdapter(new ItemBridgeAdapter(customArrayObjectAdapterDays));
You also have to set the number of days (28, 29, 30, 31) depending on the year and selected month.

Related

timepicker selected value text size [duplicate]

This question already has an answer here:
Implement iOS like time picker in Android
(1 answer)
Closed 5 years ago.
I want to change the selected text value size of a time picker.
Do we have any libraries for the same?
As I searched we do not have any customization in android. Need to develop a UI similar to iOS time picker.
For android brucetoo/PickView similar to IOS,
This is a helper lib for us to pick date or province like IOS system WheelView widget.
Added feature to pick time with WheelView Widget
Dependencies
compile 'com.brucetoo.pickview:library:1.2.3'
to use
DatePickerPopWin pickerPopWin = new DatePickerPopWin.Builder(MainActivity.this, new DatePickerPopWin.OnDatePickedListener() {
#Override
public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
Toast.makeText(MainActivity.this, dateDesc, Toast.LENGTH_SHORT).show();
}
}).textConfirm("CONFIRM") //text of confirm button
.textCancel("CANCEL") //text of cancel button
.btnTextSize(16) // button text size
.viewTextSize(25) // pick view text size
.colorCancel(Color.parseColor("#999999")) //color of cancel button
.colorConfirm(Color.parseColor("#009900"))//color of confirm button
.minYear(1990) //min year in loop
.maxYear(2550) // max year in loop
.showDayMonthYear(true) // shows like dd mm yyyy (default is false)
.dateChose("2013-11-11") // date chose when init popwindow
.build();

Hiding Date Field in Date Picket App Crash in Nougat OS : [Android]

I am using code to hide Date in Date picker. It worked fine in devices having OS less than 7.0 [Android Nougat] device.
((ViewGroup) dpDialog.getDatePicker()).findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).setVisibility(View.GONE);
No view is referenced, it returns null
findViewById(Resources.getSystem().getIdentifier("day", "id", "android"))

Removing AM/PM in Android Time picker Widget

Is there any way to remove the AM/PM in a Time Picker Widget?
I have this function in my application but its purpose is to select only Hour and Minutes not including AM/PM, I tried to setIs24HourView(true) but it makes the time 24hours, I only want 12 hours.
It seems there is no public method in TimePicker to directly hide or show the AM/PM chooser. However, a look at the source code will give us the name of the resource ID for that View, which we can get with the system Resources. Then it's simply a matter of finding the View, and setting its visibility to GONE.
private void hideAmPmLayout(TimePicker picker) {
final int id = Resources.getSystem().getIdentifier("ampm_layout", "id", "android");
final View amPmLayout = picker.findViewById(id);
if(amPmLayout != null) {
amPmLayout.setVisibility(View.GONE);
}
}

How To Show The Current Time in TextView in Widget

I want to show the current time in updatable textView
I can't find the true way to make it
I want it to be updated every minute
Please anyone can help me ?
Thanks
Calendar cal = Calendar.getInstance();
SimpleDateFormat oSimpleDateFormat = new SimpleDateFormat("HH:mm:ss");
String MyString= oSimpleDateFormat.format(cal.getTime());
EditText oEditText =(EditText) findViewById(R.id.MyEdit);
oEditText.setText(MyString);
try this
You should use ScheduledThreadPoolExecutor.scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
use the digital clock tag Digital Clock built in android studio 2.1.
Here it is built in tag to show time
< Digital Clock > don't use space b/w digital and clock, it was having problem while posting the answer.

Appcelerator Date picker without the days box calendar

Application type: mobile, Titanium SDK: 3.0, Platform & version: Android 4.1, Device: Samsung S3
when using the date picker i get a picker with three columns (day, month and year) but ALSO i am getting a calendar like box on the right containing the number of days. how can i remove the calendar box and keep the picker columns?? i am compiling against android 3.2 SDK
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>13</tool-api-level>
<manifest>
<uses-sdk android:targetSdkVersion="13" android:minSdkVersion="13"/>
<!--
<uses-sdk android:minSdkVersion="10"/>
-->
</manifest>
</android>
my code:
var minDate = new Date();
var curMonth = 0;
for (var i = 0; i < 12; i++) {
curMonth = minDate.getMonth();
curMonth--;
minDate.setMonth(curMonth);
}
var now = new Date();
this.visitDatePicker = Ti.UI.createPicker({
type : Ti.UI.PICKER_TYPE_DATE,
maxDate : now,
value : now,
minDate : minDate,
selectionIndicator : true
});
i added a screenshot of what i mean, maybe i will get some replies :)
my problem is the box that appears on the right of the date picker, how can i get rid of it??
ok its a bug, see Android: Add calendarViewShown to picker TIMOB-12539 jira issue.
I spend more time debugging and optimizing titanium than actually writing code and business logic. my next project wont be using Titanium for sure....not acceptable

Categories

Resources