How exactly do we use Android's MonthDisplayHelper? Ive been searching for possible widgets/views that would help me simplify my work as I would need to create a calendar. but it is just so hard. at least for me. So i saw this MonthDisplayHelper. from its members, i think i know what it can do..but what i don't get is how are we going to use it as i dont see it extending the view class nor is it an adapter. i know the question might be confusing. im heck confused right now. i hope somebody could help.
enlighten the confused :D
im sorry this came late..i have figured it out myself that MonthDisplayHelper will not make a Calendar for me. Well i hope it did. Creating a calendar functionality is not an easy task. we are faced with relatively complex algorithm.
so MonthDispalyHelper, again, will not make a calendar for you. Rather, it provides utility functionalities that would help you build your own calendar. a very good example of that is
MonthDisplayHelper mdh = new MonthDisplayHelper(viewedYear, viewedMonth);
int temp[] = mdh.getDigitsForRow(countRows);
which basically gives us as an integer array representation of which dates(digits) should go to each cell of the calendar. say for example, the first rows of the calendar of the supplied month and year(July 2011), would be {26,27,28,29,30,1,2}. from there, the job to position those digits to your layouts would be yours.
it also provides methods such as getting the number of days that the month specified have, the day of the week that the month starts, among other things.
i hope this helps.
This project uses MonthDisplayHelper, which might help understand how it works.
Related
I'm writing an app the is does a lot of calculating and I'd like to accomplish some calc when I leave an EditText. Nothing fancy, things like entering 7/16 and having 0.4375 as the result or 1.0259 * 7 and having 7.1813 as the result. The function wouldn't be used all the time but would eliminate a couple of steps when needed.
Thanks Steve
I asked the wrong question, but the comment posted got me thinking, needed to look at substrings.
I've figured out what I need.
I have been creating Spinner controls (Combo boxes/Drop downs) in one of my apps, and was surprised to find out how difficult it was to achieve all of the following features:
User facing Strings are externalized, taking advantage of strings.xml internationalisation (I18N) feature of Android.
Spinner selections operate using a System view, which facilitates not having to work with or map Strings to meaningful values (yuck).
User view to System view mapping should be easy, automated and minimal (i.e not hand rolled for every component).
Others have attempted solutions to this, but universally as far as I could see they suffer from one or many of the following problems:
UI code is creeping into their enum class which doesn’t belong there (messy), nearly all existing solutions suffered from this.
Hardcoded User facing Strings in their enum classes. Because these are not externalized you cannot do I18N using the stock Android features.
Authors typically make the Fragment or Activity an OnItemSelectedListener which perpetuates a common problem of inheritance for convenience, where composition is more appropriate.
I have developed my own solution which does this: http://www.androidanalyse.com/android-spinner-externalize-user-strings-mapped-to-system-enum/
My question is, have I missed something? This seems like something that should not have been this hard (which makes me feel like I'm possibly reinventing the wheel).
Below is some example code showing my solution in-use (which is available Apache 2 license from the link above).
String none = getString(R.string.none);
String light = getString(R.string.light);
String medium = getString(R.string.medium);
String strong = getString(R.string.strong);
SpinnerUtil.createNewSpinner(view, R.id.wind, Arrays.asList(none, light, medium, strong), WindLevel.values(),
new SpinnerItemSelectedListener<WindLevel>() {
public void onItemSelected(Spinner item, WindLevel value) {
// Take whatever action you wish to here.
}});
I would just use ArrayAdapter<WindLevel>. Yes, you created a custom typed listener, but the regular event listener gets the position and can call getItem() on the ArrayAdapter<WindLevel> to get a WindLevel properly typed.
IMHO, the vast majority of Spinner widgets will be populated with material read in from a database, the Internet, or some other dynamic data source, rather than populated by some sort of enum with display values coming from static strings that can be internationalized ahead of time.
This is not to say that your code is useless: if you find it useful, then it was worth writing. And I am sure that there are apps out there that contain your targeted pattern (i.e., a Spinner backed by an enum or equivalent where the display values are known in advance and can be internationalized) who might find your solution useful as well. Every developer who writes enough code cooks up these sorts of helper classes and the like that help map an OS or framework model into something that better fits the developer's own mental model. So long as you are not perceiving any performance issues, it's all good.
Also, note that OnItemSelectedListener is an interface; implementing that interface on an existing class is not inheritance.
I believe the reason nobody answered you is :
What problem are you trying to solve ? Spinners existed prior to your well designed attempt.
Why reinvent them in exactly the same way they exist in Android ?
http://developer.android.com/guide/topics/ui/controls/spinner.html
It is a beautiful wheel indeed you designed, but still, it is just a wheel :)
UPDATE :
I think I begin to understand what you did. This is interesting. I'm not sure why you did not go to the pattern implemented by the ListPreference with its entries and entryvalues.
In fact, I'm not sure I understand why the Android team did not go that route either.
In any case, it is worth proposing your idea to the Android framework. It is after all open source.
I am making an android app in which I need to display calendar.. I have searched a lot but not getting any useful result.
I have also downloaded project of calendar from following link:
http://code.google.com/p/android-calendar-view/downloads/list
But it is also not working infact giving exception.
CAn anyone help me how to display calendar.
Any help will be much appriciated.
Looking forward for solution.
Thanks
DatePicker its standart widget i dont think that it is really problem
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
...
// Required Java init code:
DatePicker dp =
(DatePicker)this.findViewById(R.id.widget27);
// for example init to 1/27/2008, no callback
dp.init(2008, 0, 27, Calendar.SUNDAY, null);
see this it can be helpful for you.
If you need a custom calendar for your app you can use below library.
https://github.com/ik024/CalendarLibrary
Hope it helps.
I have a problem with my ItemRenderer in Flex. I'm developping a mobile application and I'm using a list. One of the items is to set a date. But when the date is wrong I want to set a text in my messageField like : The To date must be after the From date.
The problem is I don't know (and don't seem to find it anywhere) where you can set the messagefield in multiline.
I read on a forum that's possible but no explanation how.
click me to see example
Here you can see an example of what I want (the 5the item in the list is using multiline).
I have a function in my itemrenderer to set the messagefield:
private function messageLabelFunction(item:Object):String
{
var eventMessageParameter:EventMessageParameterCount =
EventMessageParameterCount(item);
return eventMessageParameter.details;
}
I hope someone can help me.
Thanks in advance!
Kind regards,
Thibault Heylen
I found the best solution:
I kept searching and on a site there was lik e method : variableRowHeight but this didn't work in flex 4.5. I searched then again adobe forums and found this threat: adobe forum topic
So it's actually very simple. Just add height in you itemrenderer.
I hope I can help someone with this
Kind regards,
Thibault Heylen
I'm looking to create something EXACTLY like TimePickerDialog (look and feel) in Android, but it would be for MINUTES/SECONDS, not HOURS/MINUTES. Therefore AM/PM would not be relevant and would therefore allow MINUTE to be greater than 24 (making the max 59).
Is it possible to change the TimePickerDialog instance in any way to reflect this?
Any and all suggestions would be greatly appreciated. :-)
Is it possible to change the TimePickerDialog instance in any way to reflect this?
No, but the layout and source code to TimePickerDialog are both available as a starting point for implementing your own dialog.
This might help:
TimePicker with seconds:
https://github.com/IvanKovac/TimePickerWithSeconds
Have a look.
As the links in CommonsWare's answer are now dead, you might want to know that the source for TimePickerDialog is probably already on your local machine - it is included in the SDK. Try looking in the following locations:
[SDK_HOME]/sources/android-23/android/app/TimePickerDialog.java
or
[SDK_HOME]/sources/android-23/com/android/datetimepicker/time/TimePickerDialog.java
[SDK_HOME]/platforms/android-23/data/res/layout/time_picker_dialog.xml
Of course, choose the Android version that you want to borrow from. References to R. should be to android.R. Unfortunately, there seem to be some visibility issues with ValidationCallback - even on recent SDK levels.