是否可以一次加载适配器中的所有项目?
我正在使用CursorLoader,ListView和Cursor适配器,适配器中的项目都加载了滚动。 我知道我只有很少的简单项目(大约10个)所以我没有性能问题
由于
答案 0 :(得分:1)
阅读此Populating-a-ListView-with-a-CursorAdapter或此Android Cursor Example
如果你想使用一个ArrayList(来自Populating a ListView using an ArrayList):
lv = (ListView) findViewById(R.id.your_list_view_id);
// Instanciating an array list (you don't need to do this,
// you already have yours).
List<String> your_array_list = new ArrayList<String>();
your_array_list.add("foo");
your_array_list.add("bar");
// This is the array adapter, it takes the context of the activity as a
// first parameter, the type of list view as a second parameter and your
// array as a third parameter.
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_list_item_1,
your_array_list );
lv.setAdapter(arrayAdapter);