title: How to call setOnItemClickListener()
body: <p>I have a list view and I want to delete an item in list view when I click on it.<br>
  I used <code>list.setOnItemClickListener(this);</code> but 'this' is underlined in red and says,</p>
  
  <blockquote>
    <p>setOnItemClickListener (Android.Widget.AdapterView.OnItemClickListener) in AdapterView cannot be applied to (com.autohush.www.dah.MainActivityFragment1)</p>
  </blockquote>
  
  <p>I also tried <code>getActivity()</code> in place of <code>this</code> but it didn't work. What do I do?</p>
  
  <pre><code>public class MainActivityFragment1 extends Fragment {
  
      public MainActivityFragment1() {
      }
  
      private List&lt;ListItems&gt; LocationList;
      ArrayAdapter&lt;ListItems&gt; adapter;
      ListView list;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      private class MyAdapter extends ArrayAdapter&lt;ListItems&gt; {
  
          public MyAdapter(Context context, List&lt;ListItems&gt; values) {
  
              super(context, R.layout.list_item,values);
          }
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
  
              View v = convertView;
              LayoutInflater inflater = LayoutInflater.from(getContext());
  
              if( v == null){
                  v = inflater.inflate(R.layout.list_item, parent, false);
              }
  
              ListItems currLoc = LocationList.get(position);
  
              TextView theTextView = (TextView) v.findViewById(R.id.list_item_textview);
              theTextView.setText(currLoc.getLocation());
  
              ImageView theImageView = (ImageView) v.findViewById(R.id.imageview1);
              theImageView.setImageResource(R.drawable.bullet);
  
              return v;
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.list_view, container, false);
  
          final EditText txtinput;
  
          LocationList = new ArrayList&lt;ListItems&gt;();
          list = (ListView) rootView.findViewById(R.id.list_view);
          adapter = new MyAdapter(getActivity(),LocationList);
  
          list.setAdapter(adapter);
  
          txtinput = (EditText) rootView.findViewById(R.id.txtinput);
          ImageButton btnadd = (ImageButton) rootView.findViewById(R.id.imageButton);
          btnadd.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String newItem = txtinput.getText().toString();
                  if (newItem.equals(""))
                      Toast.makeText(getActivity(), "Enter Location Name", Toast.LENGTH_LONG).show();
                  else {
                      LocationList.add(new ListItems(newItem));
                      adapter.notifyDataSetChanged();
  
                      //Hide Keyboard
                      InputMethodManager inputManager = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                      inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
                  }
              }
          });
          list.setOnItemClickListener(this);
          setRetainInstance(true);
  
          return rootView;
      }
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          ListItems item = LocationList.get(position);
          LocationList.remove(item);
          adapter = new MyAdapter(getActivity(),LocationList);
          list.setAdapter(adapter);
      }
  }
  </code></pre>