Android में नियोजक/व्यवसाय कैलेंडर कैसे करें



android-layout android-intent (1)

मैं कैलेंडर करने की योजना बना रहा हूं जिसमें दिनांक के नीचे गतिशील ईवेंट शामिल हैं I लेकिन मुझे इसके बारे में अच्छा नमूना नहीं मिल रहा है एंड्रॉइड में नीचे दी गई छवि के अनुसार सही नाम क्या है या कुछ विचार साझा करें मुझे इसके बारे में कई एपीके और छवि मिली है। लेकिन इसके पीछे कोई सटीक विचार नहीं है, एंड्रॉइड इसका समर्थन करता है। मैं योजना कैलेंडर में महीना, सप्ताह, दिन के अनुसार दिखाना है। Google में खोज करने के बाद मैं यह लिख रहा हूं। क्या यह 2.3 से 4 तक के सभी संस्करणों का समर्थन करता है। मैंने ऊपर के संस्करण पर कुछ ब्लॉग व्यवसाय कैलेंडर का समर्थन किया है 4. दयालु और महान विचारों के लिए बहुत बहुत धन्यवाद।


GridView साथ कार्यान्वित करने का प्रयास करें, Gridview Adapter के लिए नीचे दिए गए कोड:

public class GridCellAdapter extends BaseAdapter //implements OnClickListener 
 {
  private final Context _context;

  private final List list;
  private static final int DAY_OFFSET = 1;
  private final String[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct","Nov", "Dec" };
  private final int[] daysOfMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  private int daysInMonth;
  private int currentDayOfMonth;
  private int currentWeekDay;
  Calendar calendar;
  private Button gridcell;

  List objects;

  // Days in Current Month
  public GridCellAdapter(Context context, int textViewResourceId, int month, int year, List objects) 
  {
   super();
   this._context = context;
   this.list = new ArrayList();
   this.objects=objects;
   Calendar calendar = Calendar.getInstance();
   setCurrentDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
   setCurrentWeekDay(calendar.get(Calendar.DAY_OF_WEEK));

   // Print Month
   printMonth(month, year);
  }

  private String getMonthAsString(int i) 
  {
   return months[i];
  }

  private int getNumberOfDaysOfMonth(int i) 
  {
   return daysOfMonth[i];
  }

  public String getItem(int position) 
  {
   return list.get(position);
  }

  @Override
  public int getCount()
  {
   return list.size();
  }

  /**
   * Prints Month
   * 
   * @param mm
   * @param yy
   */
  private void printMonth(int mm, int yy) 
  {
   int trailingSpaces = 0;
   int daysInPrevMonth = 0;
   int prevMonth = 0;
   int prevYear = 0;
   int nextMonth = 0;
   int nextYear = 0;

   int currentMonth = mm - 1;
   getMonthAsString(currentMonth);
   daysInMonth = getNumberOfDaysOfMonth(currentMonth);

   GregorianCalendar cal = new GregorianCalendar(yy, currentMonth, 1);
   if (currentMonth == 11) 
   {
    prevMonth = currentMonth - 1;
    daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
    nextMonth = 0;
    prevYear = yy;
    nextYear = yy + 1;
   }
   else if (currentMonth == 0) 
   {
    prevMonth = 11;
    prevYear = yy - 1;
    nextYear = yy;
    daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
    nextMonth = 1;
   } 
   else 
   {
    prevMonth = currentMonth - 1;
    nextMonth = currentMonth + 1;
    nextYear = yy;
    prevYear = yy;
    daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
   }

   int currentWeekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
   trailingSpaces = currentWeekDay;

   if (cal.isLeapYear(cal.get(Calendar.YEAR)))
   {
    if (mm == 2)
    {
     ++daysInMonth;
    }
    else if (mm == 3)
    {
     ++daysInPrevMonth;
    }
   }

   for (int i = 0; i < trailingSpaces; i++) 
   {
    list.add(String.valueOf((daysInPrevMonth - trailingSpaces + DAY_OFFSET) + i) + "-GREY" + "-" + getMonthAsString(prevMonth)+ "-" + prevYear+"-no");
   }

   // Current Month Days
   for (int i = 1; i <= daysInMonth; i++)
   {
    if (i == getCurrentDayOfMonth()) 
    {
     list.add(String.valueOf(i) + "-BLUE" + "-" + getMonthAsString(currentMonth) + "-" + yy+"-yes");
    }
    else 
    {
     list.add(String.valueOf(i) + "-WHITE" + "-" + getMonthAsString(currentMonth) + "-" + yy+"-no");
    }
   }

   // Leading Month days
   for (int i = 0; i < list.size() % 7; i++) 
   {
    list.add(String.valueOf(i + 1) + "-GREY" + "-" + getMonthAsString(nextMonth) + "-" + nextYear+"-no");
   }
  }

  @Override
  public long getItemId(int position) 
  {
   return position;
  }

  @Override
  public View getView(final int position, View convertView, ViewGroup parent)
  {
   View row = convertView;
   if (row == null) 
   {
    LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    row = inflater.inflate(R.layout.screen_gridcell, parent, false);
   }

   gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);

   String[] day_color = list.get(position).split("-");
   String theday = day_color[0];
   gridcell.setText(theday.trim());
   gridcell.setTag("");

   Calendar calendar = Calendar.getInstance();
      calendar.set(Integer.parseInt(day_color[3].trim()), convertMonthToInt(day_color[2].trim())-1, Integer.parseInt(day_color[0].trim()));
       int val = calendar.get(Calendar.DAY_OF_WEEK);


   gridcell.setGravity(Gravity.CENTER);

   gridcell.setBackgroundResource(R.drawable.cal_box_grey);

   if (day_color[1].equals("GREY")) 
   {
    gridcell.setBackgroundResource(R.drawable.cal_box_grey);
    gridcell.setTextColor(getResources().getColor(R.color.gray));
   }
   if (day_color[1].equals("WHITE")) 
   {
    gridcell.setBackgroundResource(R.drawable.cal_box);    
    gridcell.setTextColor(getResources().getColor(R.color.purple_dark));
    if(val == 1 || val == 7)
        {
         gridcell.setBackgroundResource(R.drawable.circle_grey_border);    
         gridcell.setTextColor(getResources().getColor(R.color.lightgray02));
        }
   }

   for (int i = 0; i < objects.size(); i++) 
   {
    if(Integer.parseInt(theday)==Integer.parseInt((objects.get(i).day))
      && day_color[2].equals(objects.get(i).month))
    {
     gridcell.setTag(objects.get(i).title+":::"+objects.get(i).address+":::"+objects.get(i).image
       +":::"+objects.get(i).day+":::"+objects.get(i).month+":::"+objects.get(i).year);
     gridcell.setTextColor(Color.parseColor("#da0078"));
    }
   }

   if (day_color[1].equals("BLUE")&& day_color[4].equals("yes"))
   {
    gridcell.setTextColor(Color.parseColor("#ffffff"));
    gridcell.setBackgroundResource(R.drawable.circle_days_fill);
   }

   if (day_color[4].equals("yes"))
   {
    gridcell.setTextColor(Color.parseColor("#ffffff"));
    gridcell.setBackgroundResource(R.drawable.circle_days_fill);
   }

   if (day_color[1].equals("BLUE")&& day_color[4].equals("no"))
   {
    gridcell.setTextColor(Color.parseColor("#ffffff"));
    gridcell.setBackgroundResource(R.drawable.circle_days_fill);
   }



   for (int i = 0; i < objects.size(); i++) 
   {
    if(Integer.parseInt(theday)==Integer.parseInt((objects.get(i).day))
      && day_color[2].equals(objects.get(i).month))
    {
     if(objects.get(i).rsvp.equals("1"))
     {
      gridcell.setTextColor(Color.parseColor("#008000"));
     }
    }
   }

   gridcell.setOnClickListener(new OnClickListener()
   {
    @Override
    public void onClick(View v) 
    {
     // TODO Auto-generated method stub
     String tag [] = list.get(position).toString().split("-");
     if(v.getTag().toString().equals("1"))
     {
      v.setTag("1");
      if(v.getId() == R.id.calendar_day_gridcell)
      {
       if (myToolTipInfoWindow == null)
       {
        addPurpleToolTipView(v);
       }
       else
       {
        myToolTipInfoWindow.remove();
        myToolTipInfoWindow = null;
       }
      }
      else
      {
      }
     }
     else if(v.getTag().toString().equals(""))
     {
      v.setTag("1");
      if(v.getId() == R.id.calendar_day_gridcell)
      {
       if (myToolTipInfoWindow == null)
       {
        addPurpleToolTipView(v);
       }
       else
       {
        myToolTipInfoWindow.remove();
        myToolTipInfoWindow = null;
       }
      }
      else
      {
      }
     }
     else
     {
      if(v.getId() == R.id.calendar_day_gridcell)
      {
       if (myToolTipInfoWindow == null)
       {
        addPurpleToolTipView(v);
       }
       else
       {
        myToolTipInfoWindow.remove();
        myToolTipInfoWindow = null;
       }
      }
      else
      {
      }
     }
     for (int i = 0; i < list.size(); i++) 
     {
      gridcell.setTextColor(R.color.purple_lite);
      gridcell.setBackgroundColor(Color.parseColor("#da0078"));
      String tags [] = list.get(i).toString().split("-");
      list.set(i,tags[0]+"-"+tags[1]+"-"+tags[2]+"-"+tags[3]+"-no");
     }
     list.set(position,tag[0]+"-"+tag[1]+"-"+tag[2]+"-"+tag[3]+"-yes");
     adapter1.notifyDataSetChanged();

    }
   });

   return row;
  }

  public int getCurrentDayOfMonth() 
  {
   return currentDayOfMonth;
  }

  private void setCurrentDayOfMonth(int currentDayOfMonth)
  {
   this.currentDayOfMonth = currentDayOfMonth;
  }

  public void setCurrentWeekDay(int currentWeekDay) 
  {
   this.currentWeekDay = currentWeekDay;
  }

  public int getCurrentWeekDay() 
  {
   return currentWeekDay;
  }
 }

screen_gridcell.xml कोड:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="60dp"
    android:layout_height="50dp"
    android:background="#ffffff"
    android:orientation="vertical" >

    <Button
        android:id="@+id/calendar_day_gridcell"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:button="@drawable/calendar_button_selector"
        android:gravity="center"
        android:textSize="13sp"
        android:textStyle="bold"
        android:textColor="#FFFFFF" >
    </Button>

</RelativeLayout>

स्क्रीनशॉट





calendar