I wanted to add a header to one of my ListViews in my application and since I haven't done this before I googled for that.
Now my first approach was to just add to the XML file a TextView before the ListView just like this:
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#98cfc8"
android:gravity="center_horizontal"
android:text="HARD" />
And it works, I have a header on top of my ListView now but in a tutorial I read about the headers was written that I should inflate it after I create it in the XML with such code:
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup) inflater.inflate(R.layout.header, listView,
false);
ViewGroup footer = (ViewGroup) inflater.inflate(R.layout.footer, listView,
false);
listView.addHeaderView(header, null, false);
listView.addFooterView(footer, null, false);
What is inflation and what does it change compared to my current approach ?