title: ListView OnItemClickListener error in Fragment
body: <p>I'm trying to add an item click listener on a ListView inside a fragment but getting errors,I'm using intellij idea.</p>
  
  <p>Here is my source code:</p>
  
  <pre><code> public static class FragmentFind extends Fragment{
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
  
          List&lt;CinemaListItem&gt; list=new ArrayList&lt;&gt;();
          list.add(new CinemaListItem("Name",0,"place",200));
  
          View view=inflater.inflate(R.layout.fragment_find,container,false);
  
          ListView listView=(ListView) view.findViewById(R.id.cinema_list);
          listView.setAdapter(new CinemaListAdapter(getActivity(),R.layout.cinema_list_item,list));
  
         listView.setOnItemClickListener((adapterView, view1, position, id) -&gt; {
             Toast.makeText(getActivity().getApplicationContext(), "ListView Clicked", Toast.LENGTH_LONG).show();
          });
  
          return view;
  
      }
  
  }
  </code></pre>
  
  <p>And these are the errors I'm getting.</p>
  
  <pre><code> Information:Using javac 1.8.0_40 to compile java sources
      Information:8/30/2015 6:04 PM - Compilation completed with 30 errors and 0 warnings in 16s 595ms
      Error:Android Dex: [App] UNEXPECTED TOP-LEVEL EXCEPTION:
      Error:Android Dex: [App] com.android.dx.cf.iface.ParseException: 
  
      InvokeDynamic not supported
      Error:Android Dex: [App] at com.android.dx.cf.cst.ConstantPoolParser.determineOffsets(ConstantPoolParser.java:226)
      Error:Android Dex: [App] at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:132)
      Error:Android Dex: [App] at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
      Error:Android Dex: [App] at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
      Error:Android Dex: [App] at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)
      Error:Android Dex: [App] at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
      Error:Android Dex: [App] at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
      Error:Android Dex: [App] at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processClass(Main.java:704)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.access$300(Main.java:83)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
      Error:Android Dex: [App] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:170)
      Error:Android Dex: [App] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processOne(Main.java:632)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
      Error:Android Dex: [App] at com.android.dx.command.dexer.Main.run(Main.java:246)
      Error:Android Dex: [App] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      Error:Android Dex: [App] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      Error:Android Dex: [App] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      Error:Android Dex: [App] at java.lang.reflect.Method.invoke(Method.java:497)
      Error:Android Dex: [App] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:161)
      Error:Android Dex: [App] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:294)
      Error:Android Dex: [App] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)
      Error:Android Dex: [App] ...while preparsing cst 0015 at offset 0000005e
      Error:Android Dex: [App] ...while parsing C:/Users/ACER 15/Desktop/Android Projects/CinemaProject/App/out/production/App/com/example/app/FragmentPageAdapter$FragmentFind.class
      Error:Android Dex: [App] 1 error; aborting
  </code></pre>
  
  <p>I actually get no errors at first but i only get them when I add the <strong>setOnItemClickLister</strong>.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edited</strong>
  Here is the adapter class:</p>
  
  <pre><code>public class CinemaListAdapter extends ArrayAdapter&lt;CinemaListItem&gt;{
  
  private List&lt;CinemaListItem&gt; list;
  
  public CinemaListAdapter(Context context, int resource, List&lt;CinemaListItem&gt; objects) {
      super(context, resource, objects);
      list=objects;
  
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
     View view =convertView;
      if(view==null){
          LayoutInflater inflater=(LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          view=inflater.inflate(R.layout.cinema_list_item,parent,false);
      }
  
      TextView name=(TextView) view.findViewById(R.id.name);
      TextView distance=(TextView) view.findViewById(R.id.distance);
  
      name.setText(list.get(position).getName());
      name.setTypeface(MyActivity.dekar);
      int dist=list.get(position).getDistance();
      distance.setText("" + dist + "m");
  
      return view;
   }
  
  }
  </code></pre>