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
Related
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?
I am developing an activity with a ListView in which I need to change the current row by another layout by clicking on the row, and I'm not finding any way to do as much as I look (I take hours searching for possible solutions and I have not seen any reference to this problem). I do not know if this can be done in Android, but if anyone has an idea of how to do this would be appreciated.
Thanks in advance.
PS: The ListView control is normal and just want to replace a layout with a different layout. I'm using the API 15.
Use a ViewSwitcher
http://developer.android.com/reference/android/widget/ViewSwitcher.html
A ViewSwitcher is -
ViewAnimator that switches between two views, and has a factory from
which these views are created. You can either use the factory to
create the views, or add them yourself. A ViewSwitcher can only have
two child views, of which only one is shown at a time.
I suggest merging the two layouts in a single one and hide the second one. In your adapter data you should have a flag or something to indicate which layout to display. When you click a row, toggle that flag for the selected item and notifyDataSetChanged() on the adapter. This will make sure the changed layout remains even if you scroll up and down and the row goes off screen.
A more optimized solution is to have different item types in the adapter.
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?
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.
i have to draw a listview with sections.
To be precise i have to display events in the different months of the year. In this the month name becomes the header of the section and the event in that month become the data inside the section.
i am currently getting data in a hashmap, with the month name as the key and an array on events in that month as an object.
how do i achieve this effect? In iphone app development i believe there is a inbuilt functionality for this, is there such a provision in android?
thank you in advance.
NOTE:
why can't i use a TableView inside a ScrollView to do the above? There is no need to go through adapters and all when i can do this. The process should become very less complex.
Due to the lack of built-in support for sectional header lists, we have to deal with section-header and caption views separably, where sectional-header should be non-clickable and should not be counted as a ListView child. For this you have to override some methods like getView, getCount etc of an efficient adapter.
Search separatedListAdapter for more references.