示例代码:

List<String> items = new ArrayList<>();
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items);
ListView listView = findViewById(R.id.listView);
listView.setAdapter(adapter);
// Add items to the data source
items.add("Item 1");
items.add("Item 2");
// Notify the adapter that the data has changed
adapter.notifyDataSetChanged();
              ifubing
          
5年前