Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:51:12+00:00 2026-05-28T07:51:12+00:00

I’m trying to build a calendar that looks like Android internal Calendar. The thing

  • 0

I’m trying to build a calendar that looks like Android internal Calendar. The thing that I would like to know is how to keep track of every cell in my View.

I have a Gridcell adapter that extends Base Adapter, here is the code:

    public View getView(int position, View convertView, ViewGroup parent)
        {

            int[][] MatrixPointer = new int[5][7];



            View row = convertView;
            if (row == null)
                {
                    LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    row = inflater.inflate(R.layout.calendar_day_gridcell, parent, false);
                }

            // Get a reference to the Day gridcell
            gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);


            if(position==34||position==6||position==13||position==20||position==27)
            {
                View v=(View) row.findViewById(R.id.right_border);
                v.setVisibility(View.GONE);
            }

            if(position>=7)
            {
                View v;
                v=(View) row.findViewById(R.id.top_border_double);
                v.setVisibility(View.GONE);
            }


            if(position<=27)
            {
                View v=(View) row.findViewById(R.id.bottom_border_double);
                v.setVisibility(View.GONE);v=(View) row.findViewById(R.id.bottom_border);
                v.setVisibility(View.GONE);
            }
            // ACCOUNT FOR SPACING

            Log.d(tag, "Current Day: " + getCurrentDayOfMonth());
            String[] day_color = list.get(position).split("-");
            String theday = day_color[0];
            String themonth = day_color[2];
            String theyear = day_color[3];
            if ((!eventsPerMonthMap.isEmpty()) && (eventsPerMonthMap != null))
                {
                    if (eventsPerMonthMap.containsKey(theday))
                        {
                            num_events_per_day = (TextView) row.findViewById(R.id.num_events_per_day);
                            Integer numEvents = (Integer) eventsPerMonthMap.get(theday);
                            num_events_per_day.setText(numEvents.toString());
                        }
                }

            // Set the Day GridCell
            gridcell.setText(theday);

            gridcell.setTag(theday + "-" + themonth + "-" + theyear);
            Log.d(tag, "Setting GridCell " + theday + "-" + themonth + "-" + theyear + " \n Position: "+position);

            if (day_color[1].equals("GREY"))
                {
                    gridcell.setTextColor(Color.LTGRAY);
                }
            if (day_color[1].equals("WHITE"))
                {
                    gridcell.setTextColor(Color.DKGRAY);
                }
            if (day_color[1].equals("BLUE"))
                {
                    gridcell.setTextColor(getResources().getColor(R.color.static_text_color));

                }
            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;
        }
    @Override
    public void onClick(View v) {

    }
}

When I use onClick method it doesn’t do anything let’s say for example:

            gridcell.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    gridcell.setText("TESTING");

                }
            });

doesn’t update anything to my View when I do some clicking. Tried also setting a click listener outside my class, in my Activity, but same with no result. I want to know every gridcells position and other information (like text, color). When I change gridcell’s color inside a function it destroys my design. For example,

            if (day_color[1].equals("BLUE"))
                {                       gridcell.setBackgroundColor(Color.BLUE);

                }

If I do this it messes up my design.

Hope you understand what I mean and take a look to my code.

Thank you!
Radu

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:51:13+00:00Added an answer on May 28, 2026 at 7:51 am

    Please try this:

    if (day_color[1].equals("BLUE")) {              
        gridcell.setTextColor(getResources().getColor(R.color.static_text_color));
        gridcell.setBackgroundDrawable(null);
        gridcell.setBackgroundResource(R.drawable.calendar_button_selector_day);
    }
    

    You have to remove the background assigned to button in grid cell. And assign your new background drawable resource. I have tried this. It works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.