package com.example.todocloud.customcomponent;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ListView;

public class ExpandableHeightListView extends ListView {

  boolean expanded = false;

  public ExpandableHeightListView(Context context) {
    super(context);
  }

  public ExpandableHeightListView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public ExpandableHeightListView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }

  /*public ExpandableHeightListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
  }*/

  public boolean isExpanded() {
    return expanded;
  }

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

  /**
   * Ha az expanded értéke true, akkor a ListView minden eleme látható, egyébként az eredeti visel-
   * kedés valósul meg.
   */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    if (isExpanded()) {
      // A legnagyobb érték beállítása szükséges, viszont az int 2 legnagyobb bitje nem használható
      // fel (ezért szükséges a ">> 2").
      int heightExpandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
          MeasureSpec.AT_MOST);
      super.onMeasure(widthMeasureSpec, heightExpandSpec);
      ViewGroup.LayoutParams params = getLayoutParams();
      params.height = getMeasuredHeight();
    } else {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

  }

}

@@ -41,16 +41,56 @@
 onent;%0A%0A
+import android.annotation.SuppressLint;%0A
 import a
@@ -211,16 +211,62 @@
 tView;%0A%0A
+/**%0A * Provide proper scrolling function.%0A */%0A
 public c
@@ -670,726 +670,687 @@
 %0A%0A  
-/*public ExpandableHeightListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) %7B%0A    super(context, attrs, defStyleAttr, defStyleRes);%0A  %7D*/%0A%0A  public boolean isExpanded() %7B%0A    return expanded;%0A  %7D%0A%0A  public void setExpanded(boolean expanded) %7B%0A    this.expanded = expanded;%0A  %7D%0A%0A  /**%0A   * Ha az expanded %C3%A9rt%C3%A9ke true, akkor a ListView minden eleme l%C3%A1that%C3%B3, egy%C3%A9bk%C3%A9nt az eredeti visel-%0A   * ked%C3%A9s val%C3%B3sul meg.%0A   */%0A  @Override%0A  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) %7B%0A%0A    if (isExpanded()) %7B%0A      // A legnagyobb %C3%A9rt%C3%A9k be%C3%A1ll%C3%ADt%C3%A1sa sz%C3%BCks%C3%A9ges, viszont az int 2 legnagyobb bitje nem haszn%C3%A1lhat%C3%B3%0A      // fel (ez%C3%A9rt sz%C3%BCks%C3%A9ges a %22%3E%3E 2%22).%0A      int heightExpand
+public boolean isExpanded() %7B%0A    return expanded;%0A  %7D%0A%0A  public void setExpanded(boolean expanded) %7B%0A    this.expanded = expanded;%0A  %7D%0A%0A  @Override%0A  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) %7B%0A%0A    if (isExpanded()) %7B%0A      measureExpandedHeight(widthMeasureSpec);%0A      setExpandedLayoutHeight();%0A    %7D else %7B%0A      super.onMeasure(widthMeasureSpec, heightMeasureSpec);%0A    %7D%0A%0A  %7D%0A%0A  /**%0A   * Measure the view, using expanded height. The highest 2 bits of integer reserved for%0A   * MeasureSpec mode, hence don't use those.%0A   */%0A  @SuppressLint(%22WrongCall%22)%0A  private void measureExpandedHeight(int widthMeasureSpec) %7B%0A    int expandedHeightMeasure
 Spec
@@ -1380,16 +1380,25 @@
 ureSpec(
+%0A        
 Integer.
@@ -1421,18 +1421,16 @@
         
- 
- 
 MeasureS
@@ -1440,21 +1440,24 @@
 .AT_MOST
+%0A    
 );%0A
-  
     supe
@@ -1490,29 +1490,270 @@
 ec, 
-heightExpandSpec);%0A  
+expandedHeightMeasureSpec);%0A  %7D%0A%0A  /**%0A   * Set expanded layout height to provide proper scrolling function, using the expanded height,%0A   * measured by calling measureExpandedHeight(int widthMeasureSpec) method.%0A   */%0A  private void setExpandedLayoutHeight() %7B%0A
     
@@ -1775,17 +1775,23 @@
 tParams 
-p
+layoutP
 arams = 
@@ -1813,19 +1813,23 @@
 ();%0A    
-  p
+layoutP
 arams.he
@@ -1860,88 +1860,8 @@
 ();%0A
-    %7D else %7B%0A      super.onMeasure(widthMeasureSpec, heightMeasureSpec);%0A    %7D%0A%0A
   %7D%0A

Simplify ExpandableHeightListView class