Add View over ListView - android

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.

Related

can I create list of buttons for Android app using listview or do I need to use recyclerview?

I was wondering if I want to create a simple list of buttons, a recycler view will be needed or if I can make do with a listview. Thank you
The simplest method would be to create the buttons and add them the view. I strongly recommend you to not do it the following example is for demonstratiom purpose:
onCreate...
LinearLayout root = findViewBy...
for (item: dataList) {
Button btn = newn Button(this);
btn.setText(item.text);
root.addView(btn);
}
In this example Im using a linear with vertical orientation, that should be inside a scrollview.
That is bad because every view is in memory at the same time. If you have just 2 or 3 buttons then there is no problem but if the number raise to hundreds then there will be memory usage problems.
This is why ListView got deprecated, because every row was rendered. Large data set made the UI slow. Instead RecyclerView literally recyle the views as the name implies. In memory there is only the view on the screen and a bit extra, so when a view leaves the window is available to be reused by the incoming row.
By the comments I can see you are also confused with views and viewgroups. A TextView is a View it can not have another View inside. If you only need to have a click, then TextViews can use a setOnClickListener, other is the case if you need the appearance of a button. Anyway, when you create an adapter you can add any layout you want.
A list of buttons can be achieved in both the ways. But ListView is outdated. So better use RecyclerView

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

How do I design my own custom schedule calendar?

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?

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.

Technique used in the news feed screen - custom view in the "new" Google Plus app - Android

I would like to know some insights or ideas regarding the custom list like view in the new google plus updated android app. I'm specifically researching to know if this was a list view or a scroll view with inflated custom views in it.
P.S this also has a custom entry in animation when user scrolls which is giving me a doubt that this could also be a list view with custom adapter which has an animation when list items are recycled via getView.
Check the screenshot for some clear understanding.
I don't have installed this app, but at least the way how it looks could be implemented with a ListView.
A custom adapter needs to be defined, and that custom adapter will inflate the layout for every entry, in the getView() method.
The layout of every entry, or with other words the layout of each row, could be represented by a RelativeLayout with all its components: The title, the +1 button, the photo, the date, etc.

Categories

Resources