I am using date and time picker in my application and referred the tutorial
from here but the problem is that when i run it on kitkat 4.2.2 it show output as follows: but when i run it on lollipop 5.1.1 it shows output
showing two different UI on same code i dont know how to fix this problem.I have also applied some validations on it but its working with first case but not with second case.Please help.
if you want it identical to the first one you can add
android:datePickerMode="spinner"
android:calendarViewShown="false"
This differs as per OS version in devices. It is a system date and time picker.
So it will be as per OS version and may - may not differ in each of the OS version.
Whatever you are seeing is correct and is OS level change.
I think you can force it to look a certain way by changing compilessdkversion and the targetsdkversion accordingly in your gradle file.
edit: on second thought, I'm not 100% sure it'll work...might cause problems on some versions.
The 100% positive way to get the classic spinner is like Maxi said to set the attribute datepickermode atribute to spinner.
To answer whats been asked of Maxi regarding timePicker. You have to set the timePickerMode attribute to "spinner" in a similar fashion to avoid the round clock interface and get the classic spinner.
<TimePicker
...
android:timePickerMode="spinner" />
Related
I'm developping an Android app and right now I'm having an issue with a part of my UI: a TimePickerDialog. I'd like the top part of the Dialog to be orange instead of the classic
I know that I could create a custome theme, but my boss want it developp in 4.0 (API 15) so that it covers almost every device.. I don't know how to set a color with using settings covered by API 21 and up..
TimePickerDialog appearance is very different in the API levels you are testing on. The biggest redesign was probably made in Lollipop (API 21), where the default dialog has a totally different (circular) look:
If you are testing on API21+, you are probably seeing this one. The background color AFAIK can be changed by tweaking the android:color* attributes in your theme. I'm not sure which one (could be android:colorAccent, android:colorPrimary...), but it is easy to determine.
However, since you are going to deploy down to API 15, and default time picker there is quite different, I would recommend using an external library to give each user the same look and feel of Lollipop.
The most used is probably this one, and allows you to style the dialog in terms of colors and much more.
API>=21:You can define <item name="colorPrimary">xxxx</item> in your style of theme
API<21:Use libary for example material libary
what i wanna do is when they click the Rate button it brings up the 5 stars for them to rate but i am getting this Attribute value expected error.
need 10 rep to post images so imma just give link to image.
Error : http://prntscr.com/7iiy1k
...what i really want is a personal helper. Teamviewer or share screen on skype and help me out with this... i just need a boost. i am experienced with Visual Studio just need help with Android Studio.
Thank you.
It seems you messed up your layout and visibility atrtibute is wrongly formatted. Change it to
android:visibility="VISIBLE, INVISIBLE, or GONE."
Not sure if you also need to add onClick since it's part of the mess
android:onClick="YourFunction"
In my application I am using Date picker dialog.During testing some emulator show date picker dialog properly but some emulator show the data picker dialog in properly.Can you explain whether this is a emulator problem or functionality problem as well as how to solve this problem.Thanks...
new DatePickerDialog(getSherlockActivity(), datePicker,
calendarTaskDate.get(Calendar.YEAR),
calendarTaskDate.get(Calendar.MONTH),
calendarTaskDate.get(Calendar.DAY_OF_MONTH)).show();
Here i enclosed the screen shot for both.
Emulator Name:
5.1" WVGA(480x800:mdpi),API level:17
Emulator Name:Nexus S(4.0",480x800:hdpi) API 12
Android's default DatePickerDialog's layout will be changed according to the API's based on its themes. For the different API's there is a different layout so if you have API below 8 it will be same as your first screenshot. As you go for higher API above 13 you will always get the different layout for your DatePickerDialog.
So Its not on our hand to maintain the same layout for DatePicker.
To me both images look ok.
If what you think is the problem is that the display is not the same it is simply due to the fact that in one emulator you use API 17 and in the other one API 12.
In those two API the look of the date picker is not the same.
Background
On Android, you can set an error indication for any EditText view when you want to show the user that what is typed there (or not typed) is wrong (called "form validations").
There is even a nice library for this (here) , and many post here are available of how to use it.
All worked well for me till I've ran it on a nexus 4 with Android 4.2 .
The problem
Sometimes, it just won't show the icons of the errors. In such a case , only when i give the editText (that has the problem) focus, it shows the bubble, but it's empty and doesn't show the icon of the error.
Also, in all cases, the bubbles are always empty.
Why does it occur, and how can I fix it?
Note: I use actionBarSherlock library so I need to use their themes or a theme that is based on theirs.
EDIT:
here are some screenshots:
android 4.2.2 :
android 2.3.5 :
EDIT:
after i thought that this was solved by itself, i've finally figured out when this bug occurs:
if the focus is on another editText which doesn't have an error, and the error of validation is on another editText , the indicator isn't shown till the editText gets focus.
Problem 1: The problem is the Theme of the application.
Try changing the theme to some darker theme like:
<style name="AppBaseTheme" parent="android:Theme.Black">
and it should solve your problem. I found this similar issue earlier and rectified this by changing the theme.
But I didn't research much but I feel that this is Android issue and the bubble should try to change the text colour according to the theme.
Let me know if it solves your problem, or not.
Problem 2: The other issue you are talking about for not taking focus, you may consider the following link: Text Truncating and Focus Issue.
----------------------------------------Updated Answer---------------------------------------------
Q1) What should I add to the theme configuration in order for it to always work, no matter what theme I use?
According to my findings here are some results:
[Note: Only applicable for devices running 3.0 and up]
If your build target is:
less than 11, then using
parent="android:Theme.Light" --> setError() message doesn't work or shows very faded text colour almost blending with color white
parent="android:Theme" --> setError() message works
greater than 11, then using
parent="android:Theme.Holo.Light" --> setError() message works
parent="android:Theme.Holo" --> setError() message works
Since, your project is supported for devices less than 11 API level and you want to support 4.0 and plus too, your best bet would be to go and integrate HoloEverywhere in your project which will solve your problem and you will be able to use your ActionBarSherlock too, for compatibility, check this SO Post.
Q2) What are the available configurations for the error indication UI ?
Mostly you can customise drawables and icons but I doubt you will be able to configure your text and background(If anyone knows more may point out on this)
I would suggest you to check this SO Post for immediate answers.
And for placing the correct focus, for every validation checks, you may place this code:
EditText.setFocusableInTouchMode(true);
EditText.requestFocus();
EditText.setError("My Error Text");
Let me know for any issues.
I tryed to use DatePicker dialog on Kindle. But Edit fields without the background! How I can to fix it (standard-way)? You can check it in emulator. I use Android 2.2 for building application.
I was having the same problem. I was able to solve it by calling the DatePickerDialog's setInverseBackgroundForced and passing in true.