Hourly list view in android - 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.

Related

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.

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?

Android - Best way to show data without large amount of layout files

Thanks for all the help recently! Another question!
In the app I'm building, I currently have a layout file with an expandable lstview where you can choose 10 options. When you choose one of those options, you pick another 4 options. From picking the week, you then have 3 more options. Each of those 3 options will currently open a new activity that has a listview with a checkbox and textview in each row, with about 10 rows each.
Instead of making 30 layout files which will probably crash the app(not sure how many it would take to crash the app), I'm thinking there has to be a better way. I have looked it up and can't really find what I'm looking for. I have read a little bit about sqlite, but wouldn't you still need separate layout files to call different parts of the tables? Is there a way to make a single layout file with a list view, and fill the listview with different data from sqlite, depending on where the click came from in the expandable list view?
For example, if they click workout 29 on expandable list view, then click Week 1, then click Day 1.. can that single layout load data from sqlite db. Then if they were to go back and say click workout 30, week 2, day 3, that same layout load different info from the db?
I'm also trying to find out how to make a double expandable list view still
Thanks again!
So this is very simple all you have to do is create a DataAdapter for the listview. You can then add list view items which bind to the onclick listener and then you can clear that list and add new elements to it. a useful link would be.
https://guides.codepath.com/android/Using-an-ArrayAdapter-with-ListView
You should be using a SQLite database for all your data (unless you plan on holding the data in memory which is not a good idea if it is a rather large amount). You should just create a simple view and keep reusing it. What you will have to do is create your own adapter (extending from BaseExpandableListAdapter for Expandable list views and BaseAdapter for normal list views) and then query the SQLite databse table for the data that you need.
If you are only displaying String items, you can directly extend ArrayAdapter and then provide the array of items that you want to display for the normal list.
As far as crashing goes, there are many apps that have well over 30 layout files. Besides even if you did start loading a lot of views, Android will automatically start destroying views as it starts running low on memory and recreate them when it is needed to do so.

Android: Show real time stamp on list view items

In my application, i have a ListView with a Custom adapter containing data like an image, 3-5 TextViews.
This data is fetched from a web server, until now i am showing something
This item is posted on Oct 10th 2012
but i want to change it to something like
This item is posted 6 days ago
So, its something like refreshing the ListView every 1 min, I dont want to use adapter.NotifyDataSetChanged() or something like that, which reCreates the whole ListView with the new data.
I just want that TextView alone to change in background and get displayed on the UI.
Thank You
One option would be to create a custom text view by extending the android TextView class and put a time task in it which update the text view message every one minute.
you can also use the
http://developer.android.com/reference/android/widget/TextView.html#onVisibilityChanged(android.view.View, int) to start and stop the timer task.
I don't think that is supported out of the box.
Since it seems you already have a Date/Calendar at hand just convert it to relative time string with a function like this: http://www.zachstronaut.com/posts/2009/01/20/php-relative-date-time-string.html
If you want real-time updates, I think your best bet is to start a background thread giving it the ListView and update the visible items periodically, however you may want to update all of them to prevent inconsistencies.
For Reference i suggest you to use below thing for change in ListView.
1.You need to get Row View for Particular item in which you want to change Textview.
2.Now from step 1 i believe you have your row view so apply change in it's child .

Categories

Resources