我一直在使用SeparatedListAdapter,这是众所周知的并且工作正常,但似乎我不能使用addSection()来添加SimpleAdapter,因为应用程序已终止.我正在提供一些代码来向您展示我正在尝试做什么,并获得一些指导以解决此问题.如果您需要任何其他代码或任何内容,请告诉我们:
// Declarations
private SimpleAdapter _resultsAdapter;
private ArrayAdapter<String> _adapter;
private List<Map<String,?>> _resultsList;
private ArrayList<String> _stringList = new ArrayList<String>();
// Much of source code here
// The following lines work (I can addSection()).
_adapter = new ArrayAdapter<String>(this, R.layout.custom_list_item, _stringList);
_sla = new SeparatedListAdapter(this);
_sla.addSection("Input Data", _adapter);
// More source code here...
// The following causes a crash
_resultsList.add(createItem(resultTitle.toString(), fieldDetails.toString())); // Loading data in a loop (works 100%)
_resultsAdapter = new SimpleAdapter(CompanyInfoServiceViewActivity.this, _resultsList, R.layout.list_complex, new String[] { ITEM_TITLE, ITEM_CAPTION }, …Run Code Online (Sandbox Code Playgroud)