title: Button not launching to new activity
body: <p>I have been trying to make a ListView which will have image, textviews and buttons.</p>
  
  <p>I am trying to get the buttons to start a new activity by using the code</p>
  
  <p><img src="https://i.stack.imgur.com/BGwUn.jpg" alt="button code"></p>
  
  <p>but when I use </p>
  
  <blockquote>
    <p>Intent intent = new Intent(MyListAdapter.this, Login.class);</p>
  </blockquote>
  
  <p>I get the error <code>Cannot Resolve constructor intent error</code>.</p>
  
  <p>And in the very next line</p>
  
  <blockquote>
    <p>startActivity(intent); </p>
  </blockquote>
  
  <p>I get the <code>error cannot resolve method startactivity</code></p>
  
  <p>I wanted to ask how can I get it to launch the activity I want? I have put the full code below</p>
  
  <p>Any help would be appreciated.
  Thank You</p>
  
  <hr>
  
  <pre><code>public class MyListAdapter extends ArrayAdapter&lt;Hero&gt; {
  
  //the list values in the List of type hero
  List&lt;Hero&gt; heroList;
  
  //activity context
  Context context;
  
  //the layout resource file for the list items
  int resource;
  
  //constructor initializing the values
  public MyListAdapter(Context context, int resource, List&lt;Hero&gt; heroList) {
      super(context, resource, heroList);
      this.context = context;
      this.resource = resource;
      this.heroList = heroList;
  }
  
  //this will return the ListView Item as a View
  @NonNull
  @Override
  public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
  
      //we need to get the view of the xml for our list item
      //And for this we need a layoutinflater
      LayoutInflater layoutInflater = LayoutInflater.from(context);
  
      //getting the view
      View view = layoutInflater.inflate(resource, null, false);
  
      //getting the view elements of the list from the view
      ImageView imageView = view.findViewById(R.id.imageView);
      TextView textViewName = view.findViewById(R.id.textViewName);
      TextView textViewTeam = view.findViewById(R.id.textViewTeam);
      Button test = view.findViewById(R.id.buttonDelete);
  
      //getting the hero of the specified position
      Hero hero = heroList.get(position);
  
      //adding values to the list item
      imageView.setImageDrawable(context.getResources().getDrawable(hero.getImage()));
      textViewName.setText(hero.getName());
      textViewTeam.setText(hero.getTeam());
  
      //adding a click listener to the button to remove item from the list
  
      test.setOnClickListener(new View.OnClickListener() {
          @Override
  
          public void onClick(View v) {
              Intent intent = new Intent(MyListAdapter.this, Login.class);
              startActivity(intent);
          }
  
      });
      return view;
  
  
  }
  </code></pre>