Displaying Calendar in an Android App - android

I would be obliged if someone could provide me a solution as to which component to be used so that I can display a fairly good looking calendar in my Android application.
I kept browsing for a solution for the past two days, but unfortunately could not find a solution. Since this is a very basic requisite, I am sure that there will be a perfect solution for this.
Please help with suggestions, comments and solutions.
Any help in this regard is well appreciated.
Looking forward,
Regards,
Rony

The only way to do this is to develop your own calendar widget from scratch

I am also searching for this. For now, the only thing available seems to be this:
http://code.google.com/p/android-calendar-view/
However it lacks swipe gestures, does not work on landscape, or higher density screens.

Your question may be from 2010, however it still shows up on my first result page while googling the same question.
Therefore, I felt like I should share the 2 library I eventually selected that doesn't seem to be depreciated yet :
Caldroid from Thomas Dao and Times Square from Jake Wharton.

You would have to use a gridView for the month view, a list view for the agenda view and the scroll view for the day view. You could also use a gridView for the week view. For the grid, you could set the col # to 7 so that you get 7 columns for 7 days and have another child gridView to display the weekdays as headers. For the day, you could add a framelayout inside the scroll view. this would ensure that you can overlap and add multiple events to s single column. for the agenda view it would be simple to just use a list view and set list items using a list adapter.

Related

How to create multilevel recyclerview in Android kotlin?

I want to create 3 level RecyclerView like tree view in kotlin. Is there any tutorial and suggestions please let me know.
I already tried so many times with ExpandableListView and 3 RecyclerView, but didn't find any proper solution.
By a multi-level RecyclerView, do you mean a RecyclerView with paths to different lists that branch depending upon which item has been selected? If that's the case, I would honestly recommend using a single adapter to cycle through multiple lists depending upon user input.
If you have a root list containing two items, each of which opens up its own list with its own unique set of data, you can easily implement code that notifies the adapter of which item in the root list was selected. From there, the adapter can update and switch the view accordingly. This can be applied to series of lists ad nauseam if you so choose, though I can't say I would recommend this kind of method for incredibly complex webs of lists that interact with each other.
Like Ircover said in their comment, I don't think a tree is necessary in this situation either, if only because (1) as stated, it isn't really best practice to do so for the kind of application you're making, and (2) it may unnecessarily over-complicate whatever you're trying to achieve with these branching paths in the first place. If you're willing/able to provide more information about what you're trying to do here, that may help others help you more precisely than I can :)
Full disclosure here: the blog post linked above is not a direct match that will solve your problem - it pertains specifically to displaying different types of data sets (from data classes and what have you,) but employs code that shows how different sets of data can be switched between in a single RecyclerView. Even if it isn't a god-sent solution or is only halfway helpful in solving your problem, I think it can provide some useful information to you.
Maybe a slightly dated question but looking into the same concept and I located this page https://blog.usejournal.com/multi-level-expandable-recycler-view-e75cf1f4ac4b .
They have made a single adapter class to take care of all the navigation and so far seems to be the least complicated example of an expandable RecyclerView, though not in kotlin.

Achieving Custom Day View in Android

Hi everyone, I'm try to make a custom day view in application, similar to the Google Calender's day view.
There are two things that I need to figure out:
How to display an event on top of a ListView similiar to event of
the 'Laliga match' in the reference image.
How to create events through selecting hours on the list, should I
use buttons, checkboxes or what?
I'm kinda stuck here, any help would be appreciated! Thanks.

How to get rid of long scrolls on RecyclerView

This question might seem common to you, But I didn't find any compelling answer, So I brig it up and hope you can help.
If we have a large number of items to show in a RecyclerView, And by large I mean really large like thousands (but not at the same time), Scrolling from first item to the other items will be a real pain because of many items we have to navigate.
Possible Solution: At first look maybe breaking items to smaller parts and use of a SeekBar or a group of Buttons (like page number buttons on stackoverflow questions page) in order to choose each part(page) to review seems like a not bad idea.
Question: I'm curious is there any better and clean way to achieve this? Did android predict any tools or solution for this type of issues or it's up to developer like the solution I mentioned before?
Any advice means a lot to me and I appreciate that.
What you are looking for is called pagination. Do not query for the entire 1000 records, query for first 20 and when recyclerView is scrolled to the bottom, query for next 20. It is standard way (in list or gridview too)
You must modify your service endpoints or database query to support this.

Building an infinitely scrollable calendar-like view in Android

This is not a code problem, I interpret the guidelines as that being OK.
I've been researching a way of building an infinitely scrolling calendar-like view in Android, but I've reached an impasse.
Right now my dilemma is that most of the similar views available have their children placed relative each other in a recurring style. With this I mean:
item 4 comes after item 3, which comes after item 2, and there is constant padding/margin between all items.
What I need is a way to produce an infinitely long scrollable view that may, or may not, contain items. The items should be placed at variable positions within the view. The best way I can describe a similar looking view is a one-day calendar-like view that is infinitely scrollable.
So far my best two bets are using the new RecyclerView with a custom LayoutManager (this seems very complex and still not perfectly documented by Google though). I like this approach because, among other things, it is optimized for displaying large sets in a limited view.
My other solution would be to build a completely custom View. However, with that solution I loose the adapter unless I build a container view (which is probably more complex than building a layout manager).
How would you go about solving such a problem? Tips are appreciated, I don't need code examples, just ideas which path is the best to solve this problem.
Thanks.
Apologies if I've misunderstood the guidelines
Edit: How I resolved this problem
My first solution to use RecyclerView with a special Decorator seemed promising, but it remained a "hack" so we decided not to go for that solution since we were afraid of the complications that it would create down the line.
To solve the problem I went with a SurfaceView instead of an Adapter, this means having to rewrite all the adapter-functionality for my SurfaceView but it seemed to be the best way of solving this issue of very custom drawing and layout managing for my use-case.
It still would be nice to build a custom Viewgroup that can handle this kind of layout problems.
ListView and ListAdapter are based on a fixed list, so the current infinite-scrollers just keep adding more and more data to the end of the list.
But what you want is scroller similar to Google's Calendar app which has a bi-directional infinite scroller. The problem with using ListView and ListAdapter in this case is that if you add data to the front of the list, the index of any one item changes so that the list jumps.
If you really start thinking about this from the MVC perspective, you realize that ListAdapter does not provide a model that fits this need.
Instead of having absolute indexing (i.e. 1, 2, 3, 4, etc), what you really want is relative indexing, so instead of saying "Give me the item at index 42" you want to say "here's an item, give me the five items before it". Or you have something like a calendar date which is absolute; yet — unlike your device's memory — it has effectively no beginning or end, so what you really want here is a "window" into a section of that data.
A better data model for this would be a kind of double-ended queue that is partly a LRU cache. You place a limit on the number of items in the structure. Then as prior items are loaded (user is scrolling up) the items at back end are pushed off, and when subsequent items are added (user is scrolling down), items at the front are pushed off.
Also, you would have a threshold where if you got within a few items of of one edge of the structure, a "loadNext" or "loadPrevious" event would fire and invoke a callback that you set up to push more data onto the edge of the structure.
So once you've figured out that your model is completely different, you realize that even RecyclerView isn't going to help you here because it's tied to the absolute indexing model. You need some sort of custom ViewGroup subclass that recycles item views like a ListView, but can adapt to the double-ended queue. And when you search code repos for something like this, there's nothing out there.
Sounds like fun. I'll post a link when I get a project started. (Sadly, it won't be done in any timely manner to help you right now, sorry.)
Something that might help you a little sooner: look at Google's Calendar implementation and see how they did it: Google Calendar Git repo
What you may be searching for is a FragmentStatePagerAdapter , where you can implement a swiped view, meaning when the user (for example)swipes to the right, a completely new view is displayed.
Using a FragmentStatePagerAdapter , you can handle a huge amount of views without overflowing the memory, because this specific PagerAdapter only keeps the views' states and is explicitly meant to handle large sets of views.
Keeping your example of a calendar, you can implement swiped navigation between for example weeks and generate the week views on demand while only keeping for example the year and the week's number as identifiers.
There are plenty of online tutorials for Android, maybe you have a look at this one

Best way to create a week or day view for a calendar using GridView while getting the times right as well?

So I have decided to create my week or day views using a GridView. Getting an individual day or week and putting the events thats corresponds to it isn't so bad. But there is one thing I have no idea how to implement correctly. I would like to put events in the right time frame as well, down to the minute if possible. I was hoping to get some advice on how to possibly accomplish this. Appreciate any help.
You can definitely have a day GridView within each cell of the month GridView. Not sure what the performance would be like though. Perhaps it might be best to create your own Panel that overrides onMeasure & onLayout to put the events in the correct spots.

Categories

Resources