How to add icon or change calendar icon?

I am developing a calendar application, and here is what I want to do; for example, I have different actions on different days of the month and in the calendar, I want to add an icon on days that have activity (for example, a concert). if the day has no activity, that day will not have an icon.

Note. I use CalendarView as a calendar user interface.

Here is an image I'm trying to explain;

http://postimage.org/image/kdejw72nb/

Please help me add these tiny badges on these saving days.

Thanks in advance.

+7
source share
2 answers

You will need to create your own gridView. It might look something like this:

weekday layout

<GridView android:id="@+id/weekdays" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:clickable="false" android:numColumns="7" /> 

layout.xml for days

 <GridView android:id="@+id/days" android:layout_width="wrap_content" android:layout_height="match_parent" android:numColumns="7" /> 

java code to display weekdays

 GridView weekdays = (GridView) linearLayout.findViewById(R.id.weekdays); weekdays.setAdapter(new Weekdays()); public class WeekDays extends BaseAdapter { String[] weekdays = null; public WeekDayAdapter() { DateFormatSymbols dateFormatSymbols= new DateFormatSymbols(); weekdays = = dateFormatSymbols.getShortWeekdays(); } public int getCount() { return 7; } public Object getItem(int position) { return weekdays[position]; } public long getItemId(int position) { return GridView.INVALID_ROW_ID; } public View getView(int position, View convertView, ViewGroup parent) { View view = null; view = new LinearLayout(parent.getContext()); view.setLayoutParams(new GridView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); view.setOrientation(Horizontal); LinearLayout linearLayout = new LinearLayout(parent.getContext()); linearLayout.setOrientation(Vertical); TextView weekDays = new TextView(parent.getContext()); weekDays.setText(weekdays[position + 1]); linearLayout.addView(weekDays); view.addView(linearLayout); return view; } } 

You can do something similar to set the days of the month. Feel free to ask any questions.

+3
source

Another option is to use CalendarProvider. You can refer to this: http://developer.android.com/guide/topics/providers/calendar-provider.html

+1
source

All Articles