-1
我正在使用在ListView中實現的數據庫。
我想要分段ListView並添加標題(分隔符)。我的意思是,我有很多城市,我想按分區分組。
這裏是一流的,我認爲,有事情做與頭:在ListView中顯示標題
String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
mAdapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products);
// Binding Array to ListAdapter
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));
ListView lv = getListView();
// listening to single list item on click
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
/* // selected item
String product = ((TextView) view).getText().toString();
// Launching new Activity on selecting single List Item
Intent i = new Intent(getApplicationContext(), SingleListItem.class);
// sending data to new activity
i.putExtra("product", product);
startActivity(i);*/
請參閱:http://stackoverflow.com/questions/5148376/separators-in-listview – Klaasvaak 2012-04-17 14:02:04