@Override public void handleMessage(Message msg) { dataList = new ArrayList<Map<String, Object>>(); super.handleMessage(msg); String code = (String) msg.obj; if (code != null) { switch (code) { case "200": // List<String> datas = json.getData("ChID", // person.getJSONArray("data")); // List<String> status = json.getData("Status", // person.getJSONArray("data")); List<String> datas = heballtCollectConnect.getConnectData("ChID"); List<String> status = heballtCollectConnect.getConnectData("Status"); int i; for (i = 0; i < datas.size() - 1; i++) { Map<String, Object> map = new HashMap<String, Object>(); map.put("ActivityFictionContent", "第" + datas.get(i) + "章"); dataList.add(map); } switch (status.get(i)) { case "2": isNew = true; newChapter = datas.size() - 1; chap = datas.get(i); Map<String, Object> map = new HashMap<String, Object>(); map.put("ActivityFictionContent", "第" + chap + "章(New!)"); dataList.add(map); break; default: Map<String, Object> map2 = new HashMap<String, Object>(); map2.put("ActivityFictionContent", "第" + datas.get(i) + "章"); dataList.add(map2); break; } simple_adapter = new SimpleAdapter( ActivityFictionChapter.this, dataList, R.layout.item, new String[] {"ActivityFictionContent"}, new int[] {R.id.id_txt_item}); final List<String> numb = heballtCollectConnect.getConnectData("CtID"); listView.setAdapter(simple_adapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent intent; if (arg2 != newChapter) { intent = new Intent(ActivityFictionChapter.this, ActivityFictionContent.class); intent.putExtra("CtID", numb.get(arg2)); } else { intent = new Intent( ActivityFictionChapter.this, ActivityFictionNewChapter.class); intent.putExtra("FID", one); intent.putExtra("ChID", chap); } startActivity(intent); } }); break; default: break; } } else { new AlertDialog.Builder(ActivityFictionChapter.this) .setTitle("提示信息") .setMessage("无法连接至服务器") .setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {} }) .show(); } }
public void run() { String code = heballtCollectConnect.getConnectResult(url); Message msg = Message.obtain(); msg.obj = code; handler.sendMessage(msg); }