title: Ellipsized TextView and Button with WRAP_CONTENT height of ListView
body: <p>I need to the button to make set visible depending on whether the TextView is ellipsized in the ListView.</p>
  <p>I've added OnGlobalLayout in getView to determine whether TextView is ellipsized or not.</p>
  <p>But when I set whether the button is visible or gone in onGlobalLayout, the height of the listview is not enough to draw whole item, so I can not see the button.
  (I think, it caused by height of ListView is WRAP_CONTENT. It seems that the height of ListView was set before the button's visibility was determined.)</p>
  <p>If I change the height of ListView to MAX_PARENT, I can see whole items normally.</p>
  <p>Can anyone help me on how to solve it?</p>
  <p>Here is my code,</p>
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
      ...
      holder.textView.setText(item.myText);
      holder.textView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
          @Override
          public void onGlobalLayout() {
              holder.textView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
              holder.button.setVisibility(isEllipsized(holder.textView) ? View.VISIBLE : View.GONE);
          }
      });
      ...
  }
  
  private boolean isEllipsized(TextView textView) {
      Layout layout = textView.getLayout();
      if (layout != null) {
          int lines = layout.getLineCount();
          return lines &gt; 0 &amp;&amp; layout.getEllipsisCount(lines - 1) &gt; 0;    
      }
      return false;
  }
  </code></pre>