public class MyListActivity extends ListActivity { private static final int REQUEST_CODE = 1; private MyListAdapter adapter; private ListIn this example, we have a simple list activity that allows users to add items to the list by clicking a button. When the button is clicked, we start the `AddItemActivity` using `startActivityForResult()`. Once the user enters the name and description of the item in the `AddItemActivity`, we send the data back to the `MyListActivity` using `setResult()` and `onActivityResult()` is called. We then extract the data and add a new item to the list. Package library: android.app.items; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize the adapter and list of items items = new ArrayList<>(); adapter = new MyListAdapter(this, items); setListAdapter(adapter); // Create a button to add items Button addButton = new Button(this); addButton.setText("Add Item"); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Launch the activity to add items Intent intent = new Intent(MyListActivity.this, AddItemActivity.class); startActivityForResult(intent, REQUEST_CODE); } }); // Add the button to the layout ListView listView = getListView(); listView.addHeaderView(addButton); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { // Handle the result data and add the item to the list String name = data.getStringExtra("NAME"); String description = data.getStringExtra("DESCRIPTION"); MyItem item = new MyItem(name, description); items.add(item); adapter.notifyDataSetChanged(); } } }