这是实现onclicklistener但不起作用的代码
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) {}
}