1

this a the code that implementing the onclicklistener but its not work

protected void onPostExecute(JSONObject json) {
             pDialog.dismiss();

             try {
                    android = json.getJSONArray(TAG_OS);
                    for(int i = 0; i < android.length(); i++){
                    JSONObject c = android.getJSONObject(i);
                    String name = c.getString(TAG_VER);
                    String number = c.getString(TAG_NAME);
                    String price = c.getString(TAG_PRICE);
                HashMap<String, String> map = new HashMap<String, String>();
                    map.put(TAG_VER, name);
                    map.put(TAG_NAME, number);
                    map.put(TAG_PRICE, price);
                    oslist.add(map);
                    list=(ListView)findViewById(R.id.listView1);
                    ListAdapter adapter = new SimpleAdapter(SearchPart.this, oslist,
                            R.layout.list3,
                            new String[] { TAG_VER ,TAG_NAME,TAG_PRICE}, new int[] {
                                    R.id.pname,R.id.pnumber,R.id.pprice});


                    list.setAdapter(adapter);
                    list.setOnItemClickListener(new OnItemClickListener() {

                        @Override
                        public void onItemClick(AdapterView<?> parent, View view,int position, long id) {


                            // TODO Auto-generated method stub
                            //Toast.makeText(SearchPart.this, "You Clicked at ", Toast.LENGTH_SHORT).show();
                            Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT).show();   

                        }
                    });
                    }
                 } catch (JSONException e) {}


}
Talha Q
  • 4,350
  • 4
  • 28
  • 40
  • Why are you adding Listview onclicklistner inside onpostexecute. Place the listview intialization and all the other code inside oncreate – Talha Q Jul 25 '15 at 07:58

0 Answers0