I created an android calendar widgets. but I'm just wondering.. is it possible to override the method of CalendarView? what I really wanted is to display only the current month and daygridview not the previews days and next month days.. and I also want to remove the scrollView that allow the user to scroll up and down for the previous and next month.. I just want to have a simple calendar... Is there any body can help me please?..
this is the CalendarView that I wanted to customized..
XML CalendarView ScreenShoots
So then make a class that extends CalendarView and override according methods. There should not be a problem with it.
You could just create a gridView and set the # of columns as 7 for the # of days. Create an adapter that would then extend BaseAdapter. And in that class, you could set the # of grid cells as 42 as the max. possible grid cells is 7*6. Once done, as part of the getView() method, you could create a textview for each grid cell and fill that with the day of the month.
For setting the weekdays at the top, you could create another gridView with the same specs and set that as the headerView.
Related
My app
My App shows a ListView with CheckBoxes in each row. The CheckBoxes are saved for each day. Buttons are used to navigate between the different days.
The Problem
I want a slideable TabView instead. I tried to use ViewPager, but I donĀ“t know how to implement it the right way. The problem is that I need tabs for the days between year 2000 and now. How can I achieve this?
This is how the app should look like
I have to create a listview inside a fragment that should always display the first 3 items no matter what screen size (rest should be scrollable). These 3 items should fill up the whole available space, which means that the item height has to be adjusted dynamically. You could also say: The first three items should take up about 33% of the listview each.
Is there a way achieving this using LinearLayout and layout weights? If not, what would be the best way to to this programatically, e.g. by determining current fragment size or something like that?
I managed to get the height and width using OnGlobalLayoutListener.
After all, we decided this wasn't a good idea layout-wise, but I thought someone might find this interesting nevertheless ;)
Try using the view.setMinimumHeight(int) on the inflated layout in your list adapter and supply it with a desired height.
As for obtaining screen size you can check this SO post
Edit: Apply that method to the layout that defines each item. You need a custom adapter and do that work in your getView method
You could probably calculate the size on the fly by determining the screen size, and adjusting the height of the list items as they are created & added to the list. This question and this one might help shed also shed some light on using weights, and would clean up your code.
For exmaple I have int variable "number" that is passed throughout the program
and if the number = 7 I want to create 7 identical textviews and create 7 IDs for each of them
if the number = 5 I want to create 5 textviews etc.
My guess is that I should not create any textviews in my xml file and rather create views in my java code. Is this the right approach?
I would do this with a XML holding the EditText and a ListView in another xml, then in the Adapter of that ListView you can inflate and instanciate the EditText XML items.
This way you stay much cleaner and it might be less work if you change style etc. You do not need to take care of a scrollview yourself for more items.
Also you can have items and ListView adapting to screendensity, screensize, orientation etc. without going through a hell of code - if this is a requirement.
If the last item in the list needs to be a button, you could inflate and instanciate such an item layout too in the Adapter.
If your layout is unknown at compile time (for example, the number of Views is not known), then your only choice is to do it programatically.
I need to create many alarms, so I need a list view which contains items with a DatePicker, a TimePicker and a Delete Button. I have tried various way but I have not found a solution to this issue:
I want to be able to change the data in the DatePicker or TimePicker, which will change the data in an ArrayList for the corresponding Alarm. To do this however, I will need position, but as it is not final I cannot use it to access the Alarm in the ArrayList from my Adapter.
How would I go about doing this?
Thanks
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
ViewPager PagerAdapter not updating the View
I'm new to Android. The first thing I've decided to do is Calendar. I want to display one day's events loaded from Database on each screen (via GridView component). Sliding left is previous day's events. Sliding right is next day' events.
I've looked for some examples of pagers, such as RealViewSwitcher or Deezapps-widget, but they are all have definite number of screens. But I have potencially indefinite number of screens.
Also I tried to use only 3 fixed screens and to change their contents while sliding, but this leads to blinking, because after sliding is finished, I change the adapter for gridview and it refreshes contents. For example, I slide to the right and change left screen's gridview adapter from "yesterday" to "today", central screen's gridview adapter from "today" to "tomorrow" and right screen's gridview adapter from "tomorrow" to "day after tomorrow". This approach works fine, but refreshing contents after chaging adapter is not good!
Any ideas about how to adapt one of this pagers to indefinite number of screens?
You could try using a Gallery and setting each view of the gallery to match_parent
Have a look here: Endless Pager. It extends the PagerAdapter class and implements the OnPageChangeListener interface and can be used with the ViewPager widget (all this components are in the support library). It creates a loading element every time the page end is reached or a footer element if there are no more pages.