1

I have an android calendar, there's a dot under the selected date(or date has to-do events), what i want to do is draw a circle around the date number. Could anyone help me about this?

ImageView iw = (ImageView) v.findViewById(R.id.date_icon);
if (conditionIsTrue) {
    iw.setVisibility(View.VISIBLE);
} else {
    iw.setVisibility(View.INVISIBLE);
}

The black dot under the given date is a dot image, every time the date is selected i make the dot visible. Unfortunately i cannot find a way make the circle arounded the date. Any help will be appreciated.

enter image description here

what i want to get:

enter image description here

Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125

1 Answers1

1

I've also used same code in one of my calendar application. Just try this one. In your activity class say one static variable public static int bgCal = 0; . Now in setOnItemClickListener method of gridView assign this variable like - bgCal = position + 1; And in the getView method of Adapter class use this variable like below code-

View v = convertView;

    try {
        if (YourActivityName.bgCal == position + 1) {
            v.setBackgroundResource(R.drawable.circle_drawable_image);

        } else {
            if ((Integer.parseInt(gridvalue) > 1) && (position < firstDay)) {
                v.setBackgroundResource(R.drawable.default_drawable_image);

            } else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
                v.setBackgroundResource(R.drawable.default_drawable_image);

            } else {
                v.setBackgroundResource(R.drawable.default_drawable_image);

            }
            ImageView iw = (ImageView) v.findViewById(R.id.date_icon);
            iw.setImageResource(R.drawable.dot_green);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Use your circle image in the place of circle_drawable_image which you want to set on date selected and use your default image in the place of default_drawable_image for every gridView item. It may be help you. Happy Coding :)

Priyanka
  • 677
  • 5
  • 20
  • can u pl come online in SO chats http://chat.stackoverflow.com/rooms/13436/smart-developers-lab – Erum May 20 '15 at 05:52