I have an activity and I want to put a simple title strip like the picture below(Select a category) but I can't find anything on how to do a simple one. Only title strips for tabs. Is anyone know how to implement this? Thanks :)
I think this will be your best solution - http://javatechig.com/android/listview-with-section-header-in-android.
Check the custom adapter in the link. You could also have multiple headers too, but if you only want one, then you can just have the code like below
package com.javatechig;
import android.app.ListActivity;
import android.os.Bundle;
public class SectionListView extends ListActivity {
private CustomAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAdapter = new CustomAdapter(this);
mAdapter.addSectionHeaderItem("Select A Category"); // <--- here
for (int i = 1; i < 30; i++) {
mAdapter.addItem("Item: " + i);
}
setListAdapter(mAdapter);
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments