title: How to open different Activities with my listView items?
body: <p>I have a String-Array with 9 different strings, and created a listView with this Strings; Now I would like to open a different Activity when I  click on each Element of my listView. I already tried </p>
  
  <pre><code>row.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          startActivity(new Intent((Activity)context, Workouts.class));
      }
  });
  </code></pre>
  
  <p>But it only opens the same Activity for all Items. It would be very nice if you could provide me a working code, because i have already tried to manage this problem.</p>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends Activity implements OnItemClickListener {
  
      private DrawerLayout drawerLayout;
      private ListView listView;
  
      private ActionBarDrawerToggle drawerListener;
      private MyAdapter MyAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState){
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
          drawerLayout=(DrawerLayout) findViewById(R.id.drawerLayout);
  
          listView=(ListView)findViewById(R.id.drawerList);
          MyAdapter=new MyAdapter(this);
          listView.setAdapter(MyAdapter);
          listView.setOnItemClickListener(this);
  
          drawerListener= new ActionBarDrawerToggle(this, drawerLayout,     
          R.drawable.listmenu,
          R.string.drawer_open, R.string.drawer_close){
  
              @Override
              public void onDrawerClosed(View drawerView) {
                  // TODO Auto-generated method stub
                  super.onDrawerClosed(drawerView);
              }
  
              @Override
              public void onDrawerOpened(View drawerView) {
                  // TODO Auto-generated method stub
                  Toast.makeText(MainActivity.this, " Drawer Opened ",   
                  Toast.LENGTH_SHORT).show();
              }
  
          };
  
          drawerLayout.setDrawerListener(drawerListener); 
  
          getActionBar().setHomeButtonEnabled(true);
          getActionBar().setDisplayHomeAsUpEnabled(true);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // TODO Auto-generated method stub
  
          if (drawerListener.onOptionsItemSelected(item))
          {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          // TODO Auto-generated method stub
          super.onConfigurationChanged(newConfig);
  
          drawerListener.onConfigurationChanged(newConfig);
      }
  
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onPostCreate(savedInstanceState);
          drawerListener.syncState();
      }
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,        
      long id) {
      }
  
      public void selectItem(int position) {        
          listView.setItemChecked(position, true);
      }
  
      public  void setTitle(String title)
      {
          getActionBar().setTitle(title);
  
      class MyAdapter extends BaseAdapter {
          private Context context;
          String[] planets;
  
          int[] images = { R.drawable.home, R.drawable.workout, R.drawable.week,
              R.drawable.gallery, R.drawable.statistics, R.drawable.settings};
  
              public MyAdapter(Context context) {
                  this.context=context;
                  planets=context.getResources().getStringArray(R.array.planets);
              }
  
              @Override
              public int getCount() {
                  // TODO Auto-generated method stub
                  return planets.length;
              }
  
              @Override
              public Object getItem(int position) {
                  // TODO Auto-generated method stub
                  return planets[position];
              }
  
              @Override
              public long getItemId(int position) {
                  // TODO Auto-generated method stub
                  return position;
              }
  
              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
                  // TODO Auto-generated method stub
  
                  View row =null;
  
                  if (convertView==null)
                  {
                      LayoutInflater inflater = (LayoutInflater)            
                          context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
                      row=inflater.inflate(R.layout.custom_row, parent, false);
                  }
                  else
                  {
                      row = convertView                    
                  }
  
                  row.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          startActivity(new Intent((Activity) context, Workouts.class));
                      }
                  });
  
                  TextView titleTextView = (TextView) row.findViewById(R.id.textView1);
                  ImageView titleImageView = (ImageView) row.findViewById(R.id.imageView1);
  
                  titleTextView.setText(planets[position]);
                  titleImageView.setImageResource(images[position]);
                  return row;    
              }
          }
      }
  </code></pre>