@Override public void onStop() { super.onStop(); JPushInterface.activityStopped(this); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_type_1); // initialize back button Button bakBtn = (Button) findViewById(R.id.top_bak_btn); bakBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { back(); } }); // initialize the view TextView titleText = (TextView) findViewById(R.id.top_title_txt); titleText.setText(R.string.huodong); ListView listView = (ListView) findViewById(R.id.listView_list_1); // set content SimpleAdapter adapter = new SimpleAdapter( this, data, R.layout.huodong_list_item, new String[] {"date", "title", "place"}, new int[] {R.id.huodong_item_date, R.id.huodong_item_title, R.id.huodong_item_place}); listView.setAdapter(adapter); listView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { Intent intent = new Intent(HuodongActivity.this, HuodongDetailActivity.class); intent.putExtra("id", (String) data.get(pos).get("id")); startActivity(intent); } }); DataChangeHandler dataChangeHandler = new DataChangeHandler() { final List<HashMap<String, Object>> data = HuodongActivity.this.data; @Override public void changeData(String strData) { if (strData == null) { // finish(); return; } data.clear(); try { JSONArray jsonData = new JSONArray(strData); int len = jsonData.length(); for (int i = 0; i < len; i++) { JSONObject jsonItem = jsonData.getJSONObject(i); HashMap<String, Object> item = new HashMap<String, Object>(); item.put("id", jsonItem.getString("id")); item.put("date", jsonItem.getString("date")); item.put("title", jsonItem.getString("title")); item.put("place", jsonItem.getString("place")); data.add(item); } } catch (JSONException e) { Log.d(TAG, "json data parse error!"); Log.e(TAG, e.getMessage()); } } }; new UpdateListTask(this, adapter, dataChangeHandler).execute(URL); }
private void back() { super.onBackPressed(); }