您好我正在尝试使用SimpleCursorAdapter创建一个具有如下所示的分隔符或标题的ListView
我的数据来自我的本地数据库,这就是为什么我尝试使用SimpleCursorAdapter但我在创建标题时遇到了困难 通过使用我的标题,它将按日分开活动
我为我的标题创建了一个单独的layout.xml,为我的items_list
创建了另一个layout.xml文件这是我的代码
public class List_of_Activities extends Fragment {
DBHelper dbHelper;
private SimpleCursorAdapter dataAdapter;
private SimpleCursorAdapter headerAdapter;
String[] details = new String[] {
DBHelper.KEY_TITLE,
DBHelper.KEY_TIME
};
String[] header_column = new String[] {DBHelper.KEY_DISPLAY};
// the XML defined views which the data will be bound to
int[] to = new int[] {
R.id.title,
R.id.desc,
};
int[] header_to = new int[] {
R.id.header,
};
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v =inflater.inflate(R.layout.tab_programme, container, false);
initialazeDatabase();
Cursor cursor = dbHelper.getDetailsItems();
Cursor header_cursor = dbHelper.getDayHeader();
headerAdapter =new SimpleCursorAdapter( getActivity(), R.layout.text_list_item_layout, header_cursor, header_column, header_to, 0);
dataAdapter = new SimpleCursorAdapter( getActivity(), R.layout.text_list_item_layout, cursor, columns, to, 0);
ListView listView = (ListView) v.findViewById(R.id.listView1);
// Assign adapter to ListView
listView.setAdapter(dataAdapter);
return v;
}
在我的代码中它只显示详细信息。我怎么把它们结合起来?
任何人都可以告诉我如何做到这一点?或者它的示例代码?非常感谢您的帮助