How do I design my own custom schedule calendar? - android

An Event object stores a UserTask object, an int scheduledTime, and a boolean[] daysOfWeekToRepeat denoting the days of the week when it should be repeated.
These Event objects are inserted into a sparse array
List<ArrayList<Event>> calendarEventsMatrix.
The structure has been tried and tested, so it works. My next step is to now design a UI that allows the user to see those events on a calendar. The user can also click on those events and add, edit, or delete events.
Here is my current design plan:
Create an EventSlot.class that extends LinearLayout. This will be the basis for the entire calendar. Each EventSlot view will have its own onClickListener.
Create a WeekColumn.class that extends LinearLayout. This WeekColumn will be a vertical LinearLayout that will fill itself with a bunch of EventSlot views that will somehow be numbered for every hour of the day.
Create a EventsFrame.class that will extend LinearLayout. EventsFrame will be a horizontal LinearLayout that will fill itself with 7 of these WeekColumn views (one for every day of the week).
Create a CalendarFrame.class that will extend ViewGroup. This will simply be the container for the EventsFrame, as well as other useful TextViews and labels. The CalendarFrame is what will be inflated and placed into my Fragment.
Assuming all of that has been set up, my next step is to assign the events in my calendarEventsMatrix to the calendar with an adapter.
Is my thinking correct?
My concern is that I don't want to be inflating a whole bunch of these views every single time the user wants to open up the schedule calendar. Should I be doing things from XML or dynamically? And what is the best adapter to extend for this calendar?

Related

Put Layout above multiple rows of ListView

I am doing app as Google Calendar to add events.
The Google Calendar uses this UI:
When you create an Event, it draws a blue Layout(or TextView) to represent the duration of the Event.
I am trying to do that effect. I have my ListView where each row represents one hour.
If I have a Event with 2.5 hour of duration, the Layout must be on 2 and a half rows of the ListView.
How can I draw a single Layout on multiple rows?
I am using a custom ListView with a custom Adapter. I understand when you override getView() in the Adapter, you draw just one row of the list. I don't know if this is the correct approach to do this.
Thanks for your help and sorry for the bad english.
I guess Google Calendar use custom container instead of ListView for doing that. If you take a look at original calendar with switched on "Show layout bounds" or by using DDMS you will see following:
So to achive the same behavior, taking in account that GC Event could be scheduled with 5min precision the best way to achive this is by manualy manipulating views on layout (creating own container for Event views).
Also you could take a look on existing libraries like following:
Calendar-Day-View
Android-Week-View

What sort of layout would I use for a custom day view calendar? (Android)

I've read a lot of different questions on stackoverflow about custom day view calendars. Right now my project is using a listview to display all the events on one single day (e.g. Monday).
How would I implement the hours alongside with a listview while expanding the items proportional to their time duration?
I'm asking for the layout(s) required to do this, not the logic for sorting and assigning the items of the listview.
For instance, my goal is to get something similar to the Microsoft Day View:
Would I create a gridview instead and place the times on the leftmost grid? Then I should have the right column be filled to X dp based on the time?

Hourly list view in android

I'm trying to implement a simple calendar as my first Android app, but I don't know how I would go about implementing the daily view which consists of a ListView of all available hours, including those that have an event assigned to them.
Should I generate the empty hours and insert them into an ListView? Is there any better way?
Thanks!
You insert into your ListView what you want to show to your users. If you want to show a row of empty case for those hours without an event then yes you put those hours into the ListView. However, if you want to represent a collapsed view where only the hours with an event are shown then you don't include the other hours.
A good idea would be to represent only the hours with events but expand the list to dynamically include the other hours for the day when the user touch on it and vice-versa.
You could also use an ExpandableListView if you want to have something more like an hierarchy but using an ExpandableListView is not essential if you want to dynamically add or remove items to your ListView.

Add View over ListView

I want to create calendar. I want to use ListView as Hours For day viewing .
I came across a problem For showing events in day. I use my View as event.When I want to show my View between two hours, every thing is good(because simply in getView() method in adapter I inflate my View and show it ) but I can't show my View between two times that aren't between two hours.
For example I can't show my View between 2:30 and 3:30. I want to add my View over ListView.
This is ICS calendar, I want some thing like this:
You can see event between 5:30 and 6:30.
Use Relative layout to create 'layers'. Your bottom layout will be ListView and TextView as a top. But this layout can cause a lot of headache.
I recommend to create custom component (based on LinearLayout) where you can draw hours yourself and place TextView using absolute positioning.

Access a custom ListView item

l'm new here so hope to follow guidelines as I'm a newbie for both the side and android.
For my first app I'm trying to make a world clock.
In order to check it the time is shown and update in seconds. (00:00:00)
As the only thing I want to update every second is the time I don't want to use:
ListView's notfiyDataHasChanged()
I have a custom ListView & extended BaseAdapter and row.xml with each ListView item layout.
Trying:
lv.getChildCount() returns 0;
So I understand it has no child.
But I don't know how I can retrieve the View of the specific item in the listview.
Then call that view's TextView by findViewById(R.id.time) and set it each second.
I've googled and read alot of threads but still didn't get that :(
Thank You.
I would go a different way about that problem: Subclass the TextView widget into your own TimeView widget and include that one in your row layout.
The TimeView widget will own a handle that calls itself to refresh the view.
Hence, automatically, all views visible in the list will update themselves, the other adapter items will not be having views and won't as a consequence require any update.

Categories

Resources