I want to create weekly calendar view and inside each grid item (each day) there are may be several activities.Out of this I have created weekly calendar view using grid view but I want to add activities if there are any for particular date by dynamically checking db. Like same as in image. Below is my getView() code..
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.calendar_week_gridcell, parent, false);
}
txtRowTitle = (TextView) row.findViewById(R.id.txtDayTitle);
LinearLayout root = (LinearLayout) row.findViewById(R.id.linear_root);
String dayTitle = list.get(position);
txtRowTitle.setText(dayTitle);
if (position == currentWeekDay - 1)
root.setBackgroundResource(R.drawable.calheader);
if (!activityMap.isEmpty() && activityMap.containsKey(activityDateList.get(position))) {
TextView item = new TextView(mContext);
item.setText(activityMap.get(activityDateList.get(position)));
item.setBackgroundColor(Color.GREEN);
root.addView(item);
}
return row;
}
}
Here I am temporarily trying to add text view dynamically but I want to inflate here my custom activity_item layout and add it to grid cell.