title: How to start an activity from a custom ListView?
body: <p>I have a custom listview in which I can add as many elements as I want. All of these elements must open an activity (which is called "Compile" in my project) with a few edittext stuff to fill. The problem is that I don't actually know what to write in my code to tell the app to open the Compile activity when one of the elements is clicked. </p>
  
  <p>//(Obviously every element must open its Compile activity with its relative informations. For example: element "Pizza" must open the activity Compile in which there are all the infos I previously put about Pizza.)//</p>
  
  <p>Thanks for the support </p>
  
  <p>This is my code for the listview:</p>
  
  <pre><code>public class Sheet extends Activity {
  
      private static final int DIALOG_ALERT = 10;
  
      ListView list;
      ImageView addBtn;
      EditText input;
  
      String[] items;
      MyListAdapter adapter;
      AlertDialog alert;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_sheet);
  
          list = (ListView) findViewById(R.id.list);
          addBtn = (ImageView) findViewById(R.id.addPlanBtn);
  
          input = new EditText(this);
  
          items = new String[1];
  
          alert = new AlertDialog.Builder(Sheet.this).create();
          alert.setTitle("Activity name: ");
          alert.setMessage("Type a name for your activity: ");
          alert.setView(input);
  
  
          alert.setButton("add", new DialogInterface.OnClickListener() {
  
              public void onClick(DialogInterface dialog, int which) {
                  String value = input.getText().toString();
  
                  items[items.length - 1] = value;
  
                  adapter = new MyListAdapter(Sheet.this, items);
                  list.setAdapter(adapter);
  
                  String[] temp = new String[items.length +1];
  
                  for(int i = 0; i&lt; items.length; i++)
                      temp[i] = items[i];
  
                  items = temp;
  
                  alert.dismiss();
                  adapter.notifyDataSetChanged();
  
              }
  
          });
  
          addBtn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  alert.show();
              }
          });
  
      }
  </code></pre>