コード例 #1
0
  @Override
  public RemoteViews getViewAt(int position) {
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.day_view);

    DayInfo dayInfo = dayInfoList.get(position);
    setTextView(remoteViews, R.id.text_day, dayInfo.getDay());
    setTextView(
        remoteViews,
        R.id.text_title1,
        dayInfo.getItemList().size() > 0 ? dayInfo.getItemList().get(0) : null);
    setTextView(
        remoteViews,
        R.id.text_title2,
        dayInfo.getItemList().size() > 1 ? dayInfo.getItemList().get(1) : null);
    setTextView(
        remoteViews,
        R.id.text_title3,
        dayInfo.getItemList().size() > 2 ? dayInfo.getItemList().get(2) : null);
    setTextView(
        remoteViews,
        R.id.text_etc,
        dayInfo.getItemList().size() > 3 ? "" + (dayInfo.getItemList().size() - 2) : null);

    setDefaultDayColor(remoteViews, position);

    Intent intent = new Intent();
    intent.putExtra(CalWidgetProvider.ACTION_POSITION, position);

    return remoteViews;
  }