How can I use OnItemClick method in a listview?
<p>Hello I have a problem with my listView I have an error with my OnItemClick methd</p>

<blockquote>
  <p>FATAL EXCEPTION: main java.lang.ClassCastException: com.example.dell.app3.Product cannot be cast to java.util.HashMap</p>
</blockquote>

<pre><code>private void showProduct(String json){
        JSONObject jsonObject = null;
        ArrayList&lt;Product&gt; productList = new ArrayList&lt;&gt;();
        try {
            JSONArray result = new JSONArray(json);
            for(int i = 0; i&lt;result.length(); i++){
                JSONObject jo = result.getJSONObject(i);
                String name = jo.getString("Nom");
                String ref = jo.getString("Reference");
                String image1 = "http://aaaa.com/Scripts/images/"+jo.getString("image")+".jpg";
                Product product = new Product();
                product.setName(name);
                product.setRef(ref);
                product.setImageUrl(image1);
                productList.add(product);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        adapter = new CustomArrayAdapter(getContext(), productList);
        listView.setAdapter(adapter);
    }
</code></pre>

<p>OnItemClick method</p>

<pre><code>public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
        Intent intent = new Intent(getActivity().getApplicationContext(), ViewProduct.class);
        HashMap&lt;String, String&gt; map = (HashMap) parent.getItemAtPosition(position);
        String tid = map.get("ref").toString();
        intent.putExtra("ref", tid);
        startActivity(intent);
    }
</code></pre>

<p>I have an error also with my inputSearch</p>

<pre><code>inputSearch.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                ((CustomArrayAdapter) ProduitsFragment.this.adapter).getFilter().filter(cs);
            }
            @Override
            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                                          int arg3) {
            }
            @Override
            public void afterTextChanged(Editable arg0) {
            }
        });
</code></pre>

<p>product.java</p>

<pre><code>public class Product {
    String name;
    String ref;
    String imageUrl;

    public String getName() {
        return name;
    }
    public String getRef() {
        return ref;
    }
    public String getImageUrl() {
        return imageUrl;
    }
    public void setName(String name) {
        this.name = name;
    }
    public void setRef(String ref) {
        this.ref = ref;
    }
    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }
}
</code></pre>