How add listView header as a custom layout
<p>I want to add header in listView i try like this what i am missing here ids are fine.
<strong>I am using this in fragment.</strong></p>

<pre><code>ListView lv;

LinearLayout header = (LinearLayout) rootView.findViewById(R.id.header_layout);

lv.addHeaderView(header);
// APP is crashing here?
</code></pre>

<p><strong>Logcat</strong></p>

<pre><code>java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
            at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1732)
            at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1677)
            at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:381)
            at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:389)
            at android.view.View.measure(View.java:17547)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
            at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
            at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
            at android.view.View.measure(View.java:17547)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
            at android.view.View.measure(View.java:17547)
</code></pre>