Android Open Source - budget-envelopes T A C Grid View

From Project

Back to project page budget-envelopes.


The source code is released under:

GNU General Public License

If you think the Android project budget-envelopes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

 * This file is a part of Budget with Envelopes.
 * Copyright 2013 Michael Howell <>
 */*from  w  w  w .j a va2 s  .c  om*/
 * Budget is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * Budget is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Budget. If not, see <>.

// Got it from here:

package com.notriddle.budget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;

public class TACGridView extends GridView {

  public TACGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
  public TACGridView(Context context, AttributeSet attrs)
      super(context, attrs);

  public TACGridView(Context context)
  boolean expanded = true;

    public boolean isExpanded() {
        return expanded;

    public void setExpanded(boolean expanded) {
        this.expanded = expanded;

    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (isExpanded()) {         
            // Calculate entire height by providing a very large height hint.
            // But do not use the highest 2 bits of this integer; those are
            // reserved for the MeasureSpec mode.
            int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
            super.onMeasure(widthMeasureSpec, expandSpec);

            android.view.ViewGroup.LayoutParams params =  getLayoutParams();
            params.height = getMeasuredHeight();
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);


Java Source Code List