title: Android: how to get value of "listPreferredItemHeight" attribute in code?
body: <p>The below code gives <code>Resources$NotFoundException</code></p>
  
  <pre><code>TypedValue value = new TypedValue();
  ((Activity)context).getResources().getValue(android.R.attr.listPreferredItemHeight, value, true);
  </code></pre>
  
  <p>EDIT: More code added in response to answer.  </p>
  
  <p>When I run the below code, all members of <code>displayMetrics</code> are 0.  As is <code>ret</code>.</p>
  
  <pre><code>TypedValue value = new TypedValue();
  DisplayMetrics displayMetrics = new DisplayMetrics();
  ((Activity)context).getTheme().resolveAttribute(android.R.attr.listPreferredItemHeight, value, true);
  float ret = value.getDimension(displayMetrics);
  </code></pre>