get other values according to the item selected in Autocompletetextview
<p>My <code>AutoCompleteTextView</code> works very well. But I can't get the other values (for example <code>plant</code>, <code>qty</code>, etc.) according to the selected value from the <code>AutoCompleteTextView</code>.</p>

<p>My JSON response</p>

<pre><code>{
    "feed": [{
        "material": "2000000",
        "plant": "2100",
        "qty": "4",
        "ton": "13.68",
        "val": "5333.44",
        "des": "4.00-08 06PR C.AUTO ZEETEX",
        "matgrp": "FG0002"
    }, {
        "material": "2000001",
        "plant": "2100",
        "qty": "13",
        "ton": "46.15",
        "val": "20566.52",
        "des": "4.00-08 06PR C.M - ZEETEX",
        "matgrp": "FG0002"
    }]
}
</code></pre>

<p>JsonParse class. <code>AutoCompleteTextView</code> works perfectly.</p>

<pre><code>public List&lt;Product&gt; getParseJsonWCF(String sName) {
    List&lt;Product&gt; ListData = new ArrayList&lt;Product&gt;();
    try {
        String temp = sName.replace(" ", "%20");
        URL js = new URL(url + temp);
        URLConnection jc = js.openConnection();
        BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
        String line = reader.readLine();

        JSONObject jsonResponse = new JSONObject(line);
        JSONArray jsonArray = jsonResponse.getJSONArray("feed");
        for (int i = 0; i &lt; jsonArray.length(); i++) {
            JSONObject r = jsonArray.getJSONObject(i);
            ListData.add(new Product(r.getInt("qty"), r.getString("des"), r.getString("plant"), r.getString("matgrp")));

        }
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    return ListData;

}
</code></pre>

<p>This is my MaterialSuggestionAdapter class.</p>

<pre><code>public class MaterialSuggestionAdapter extends ArrayAdapter&lt;String&gt; {
            private List&lt;String&gt; suggestions;
            private List&lt;String&gt; originals;
            private List&lt;Product&gt; new_suggestions;
            private String matCodeName;

            public MaterialSuggestionAdapter(Activity context, String matFilter) {
                super(context, android.R.layout.simple_dropdown_item_1line);
                suggestions = new ArrayList&lt;String&gt;();
                originals = new ArrayList&lt;String&gt;();
            }

            @Override
            public int getCount() {
                return suggestions.size();
            }

            @Override
            public String getItem(int position) {
                return suggestions.get(position);
            }

            @Override
            public Filter getFilter() {
                Filter filter = new Filter() {
                    @Override
                    protected FilterResults performFiltering(CharSequence charSequence) {
                        FilterResults filterResults = new FilterResults();
                        JsonParseMaterial jp = new JsonParseMaterial();
                        if ((charSequence == null || charSequence.length() == 0)) {
                            filterResults.values = originals;
                            filterResults.count = originals.size();

                        } else {
                            // A class that queries a web API, parses the data and
                            // returns an ArrayList&lt;Product&gt;
                            new_suggestions = jp.getParseJsonWCF(charSequence.toString());
                            suggestions.clear();
                            for (int i = 0; i &lt; new_suggestions.size(); i++) {
                                if (new_suggestions.get(i).getMatName().toUpperCase().startsWith(charSequence.toString().toUpperCase())) {
                                    suggestions.add(new_suggestions.get(i).getMatName());
                                }
                            }

                            // Now assign the values and count to the FilterResults
                            // object
                            filterResults.values = suggestions;
                            filterResults.count = suggestions.size();
                        }
                        return filterResults;
                    }

                    @Override
                    protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
                        if (filterResults != null &amp;&amp; filterResults.count &gt; 0) {
                            notifyDataSetChanged();
                        } else {
                            notifyDataSetInvalidated();
                        }
                    }
                };
                return filter;

            }
        }
</code></pre>

<p>This is my <code>AutoCompleteTextView</code>.</p>

<pre><code>final AutoCompleteTextView acTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
final MaterialSuggestionAdapter adapter = new MaterialSuggestionAdapter(this, acTextView.getText().toString());
acTextView.setAdapter(adapter);
Bundle gt = getIntent().getExtras();
dealerName = gt.getString("abc");
//textView.setText(dealerName);
getSupportActionBar().setTitle(dealerName);
acTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView &lt; ? &gt; adapterView, View view, int i, long l) {
        //vPager = (ViewPager) findViewById(R.id.viewPager);
        //vPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager()));
        String newName = adapterView.getItemAtPosition(i).toString();
        //selectItemAdapter.add();
        //String s = item.getItemName();
        if (!newName.equals("")) {
            if (myRecyclerViewAdapter.getItemCount() &gt; 1) {
                myRecyclerViewAdapter.add(1, newName);
            } else {
                myRecyclerViewAdapter.add(0, newName);
            }
        }
    }
});
</code></pre>

<p>This is my stack trace friend.</p>

<pre><code>02-26 04:36:53.030 6428-6428/? I/art: Late-enabling -Xcheck:jni
02-26 04:36:53.358 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
02-26 04:36:53.456 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-26 04:36:53.469 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat D/Atlas: Validating map...
02-26 04:36:53.526 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
02-26 04:36:53.527 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
02-26 04:36:53.539 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so
02-26 04:36:53.598 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat I/OpenGLRenderer: Initialized EGL, version 1.4
02-26 04:36:53.654 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat D/OpenGLRenderer: Enabling debug mode 0
02-26 04:36:53.685 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/EGL_emulation: eglSurfaceAttrib not implemented
02-26 04:36:53.685 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xeec35700, error=EGL_SUCCESS
02-26 04:36:54.369 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat I/Choreographer: Skipped 35 frames!  The application may be doing too much work on its main thread.
02-26 04:36:57.891 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
02-26 04:36:57.969 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/EGL_emulation: eglSurfaceAttrib not implemented
02-26 04:36:57.969 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xf3fff200, error=EGL_SUCCESS
02-26 04:37:00.002 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/EGL_emulation: eglSurfaceAttrib not implemented
02-26 04:37:00.002 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe247a380, error=EGL_SUCCESS
02-26 04:37:01.481 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/EGL_emulation: eglSurfaceAttrib not implemented
02-26 04:37:01.481 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe247aee0, error=EGL_SUCCESS
02-26 04:37:01.990 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
02-26 04:37:02.107 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/EGL_emulation: eglSurfaceAttrib not implemented
02-26 04:37:02.107 6428-6464/com.ceatkelanisrilanka.dushanmadushanka.ceat W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xf3ffffa0, error=EGL_SUCCESS
02-26 04:37:03.220 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat D/AndroidRuntime: Shutting down VM
02-26 04:37:03.220 6428-6428/com.ceatkelanisrilanka.dushanmadushanka.ceat E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                            Process: com.ceatkelanisrilanka.dushanmadushanka.ceat, PID: 6428
                                                                                            java.lang.ClassCastException: java.lang.String cannot be cast to com.ceatkelanisrilanka.dushanmadushanka.ceat.Product
                                                                                                at com.ceatkelanisrilanka.dushanmadushanka.ceat.MaterialSuggestionAdapter.getItem(MaterialSuggestionAdapter.java:130)
                                                                                                at com.ceatkelanisrilanka.dushanmadushanka.ceat.MaterialSuggestionAdapter.getItem(MaterialSuggestionAdapter.java:110)
                                                                                                at android.widget.AutoCompleteTextView.buildImeCompletions(AutoCompleteTextView.java:1131)
                                                                                                at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1091)
                                                                                                at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:974)
                                                                                                at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:956)
                                                                                                at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
                                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                                at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
</code></pre>

<p><strong>Update new</strong></p>

<pre><code>public class MaterialSuggestionAdapter extends BaseAdapter implements Filterable {
    private static final int MAX_RESULTS = 5;
    private Context mContext;
    private static final String url = AppConfig.URL_JSON_AVAILABLE_PRODUCTS;
    //replace this with your List&lt;Product&gt;
    private List&lt;Product&gt; mResults = new ArrayList&lt;&gt;();
    private List&lt;String&gt; locations;

    public MaterialSuggestionAdapter(Context context) {
        mContext = context;
        locations = new ArrayList&lt;String&gt;();
    }

    @Override
    public int getCount() {
        return mResults.size();
    }

    @Override
    public Product getItem(int index) {
        return mResults.get(index);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.custom_row_selected_item, parent, false);
        }

        TextView tvResult = ButterKnife.findById(convertView, R.id.txtProductName);
        tvResult.setText(getItem(position).getMatName().toString());

        return convertView;
    }


    @Override
    public Filter getFilter() {
        return new Filter() {
            @Override
            protected FilterResults performFiltering(CharSequence constraint) {
                FilterResults filterResults = new FilterResults();
                if ((constraint == null || constraint.length() == 0)) {
                    filterResults.values = locations;
                    filterResults.count = locations.size();

                } else {
                    mResults = getParseJsonWCF(constraint.toString());
                    // Assign the data to the FilterResults

                    locations.clear();
                    for (int i = 0; i &lt; mResults.size(); i++) {
                        if (mResults.get(i).getMatName().toUpperCase().startsWith(constraint.toString().toUpperCase())) {
                            //a  = new_suggestions.get(i).getMatNo();
                            locations.add(mResults.get(i).getMatName());

                        }
                    }
                    // Assign the data to the FilterResults
                    filterResults.values = locations;
                    filterResults.count = locations.size();
                }
                return filterResults;
            }

            @SuppressWarnings("unchecked cast")
            @Override
            protected void publishResults(CharSequence constraint, FilterResults results) {
                if (results != null &amp;&amp; results.count &gt; 0) {
                    mResults = (List&lt;Product&gt;) results.values;
                    notifyDataSetChanged();
                } else {
                    notifyDataSetInvalidated();
                }
            }
        };
    }

    public List&lt;Product&gt; getParseJsonWCF(String sName) {
        List&lt;Product&gt; ListData = new ArrayList&lt;Product&gt;();
        try {
            String temp = sName.replace(" ", "%20");
            URL js = new URL(url + temp);
            URLConnection jc = js.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
            String line = reader.readLine();

            //HashMap&lt;String, String&gt; map_name_value = new HashMap&lt;String, String&gt;();

            JSONObject jsonResponse = new JSONObject(line);
            JSONArray jsonArray = jsonResponse.getJSONArray("feed");
            for (int i = 0; i &lt; jsonArray.length(); i++) {
                JSONObject r = jsonArray.getJSONObject(i);
                ListData.add(new Product(r.getInt("qty"), r.getString("des"), r.getString("plant"), r.getString("matgrp"), r.getString("material")));

                //ListData.add(r.getString("des"));
                //map_name_value.put(r.getString("des"), r.getString("qty"));


            }
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        return ListData;

    }
}
</code></pre>

<p><strong>this is MaterialSuggestionAdapter.java: Line 130</strong></p>

<p>return mResults.get(index);</p>