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




android-intent android-listview calendar (2)

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


Answers

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>

स्क्रीनशॉट


Answer: (Romain Guy): The user doesn't, the system handles this automatically. That's what the activity lifecycle (especially onPause/onStop/onDestroy) is for. No matter what you do, do not put a "quit" or "exit" application button. It is useless with Android's application model. This is also contrary to how core applications work.

1: Totally exiting an application may be generally unmandatory, but it is not useless. What if windows had no exit option? System would be doggy slow as memory was full and the OS had to guess at which programs you were done with. I don't care what Romain Guy or even Larry Page and Sergey Brin say - these are unquestionable facts: Systems run slower when they have to kill tasks to get their memory before a new app can be launched. You just can't tell me that it doesn't take time to kill an app! Even the light from distant stars take time... There is some use in allowing the user to fully close apps.

2: Contrary to how core applications work? What's that supposed to mean? When I'm done running an app for now, it is no longer doing any work...It's just waiting to be killed by the OS when its memory is needed.

In summary, there is a distinct difference between minimizing and exiting, and neither pinch hits well for the other. Do we leave a screwdriver in every screw? Or a key in every door? Do we leave all of our appliances on high until the breaker blows and we need to turn on another appliance? Do we leave the dish washer full of dishes, and only take out enough each time to make room for some new dirty ones? Do we leave all the cars running in the driveway until -- oh never mind.

If the user wants to minimize an app, then the best thing is to minimize it. If a user wants to exit an app, then by all means it is best to exit.

Is it frowned on? That's Android's view - they frown on it. And many many independent rookie Android developers frown on it.

But when it comes right down to it, there is good coding and bad coding. There is good program flow models and there are bad program flow models.

Leaving programs in memory when the user knows they are done with them simply is not good program flow. It serves absolutely no purpose whatsoever, and it slows things down when launching new apps or when running apps allocate more memory.

It is sort of like your car: There are times when you leave it running, like stopping at a stop light, or perhaps the fast food drive through, or stopping at the ATM. But there are other situations where you do want to shut it off - like when you get to work, or the grocery store or even home.

Similarly, if you're playing a game and the phone rings, yes. Pause the game and keep it running. But if the user is done with the game for a while, then by all means let them exit.

The exit button on some applications should be more out in front than others. Games, for example, or programs where the user is likely to want to fully exit, should have an obvious exit. Other programs, like, perhaps, email programs, where exiting is an unlikely desire (so that it can keep checking for email) -- these programs should not waste prime control input screen space with an exit option, but for good program flow, it should have an exit option. What if someone decides they don't want their mail program trying to check email when they are in poor coverage area, or maybe in a Skype call or whatever? Let them exit the email program if they want!

Suspending and exiting are two vital tasks and neither fulfills the role of the other.





android android-layout android-intent android-listview calendar