private void doJson() { try { Log.i("json", detail); JSONArray arr = new JSONArray(detail); JSONArray main = arr.getJSONArray(0); tvSender.setText(main.getString(4)); tvSendTime.setText(HttpConstant.convertTime(main.getLong(7))); tvMsg.setText(main.getString(1)); tvLoc.setText(main.getString(6)); alert_id = main.getInt(2); Picasso.with(this).load(HttpConstant.BAIDUFACE + main.getString(5)).into(ivFace); for (int i = 1; i < arr.length(); i++) { LostBean lb = new LostBean(); JSONArray lost = arr.getJSONArray(i); lb.title = lost.optString(0); lb.description = lost.optString(1); lb.alert_id = lost.optString(2); lb.from_user_id = lost.optString(3); lb.uname = lost.optString(4); lb.uface = lost.optString(5); lb.position = lost.optString(6); lb.time = lost.optLong(7); lostList.add(lb); } adapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { convertView = getLayoutInflater().inflate(R.layout.item_detail, null); ImageView iv; TextView tvName, tvMsg, tvTime, tvLoc; iv = (ImageView) convertView.findViewById(R.id.iv_face); tvName = (TextView) convertView.findViewById(R.id.tv_name); tvTime = (TextView) convertView.findViewById(R.id.tv_time); tvLoc = (TextView) convertView.findViewById(R.id.tv_loc); tvMsg = (TextView) convertView.findViewById(R.id.tv_desc); LostBean lb = lostList.get(position); tvName.setText(lb.uname); tvTime.setText(HttpConstant.convertTime(lb.time)); tvLoc.setText(lb.position); tvMsg.setText(lb.description); Picasso.with(getApplicationContext()).load(HttpConstant.BAIDUFACE + lb.uface).into(iv); return convertView; }