Public class listview extends Activity {private LinkedHashMap
Params; private List
Data_set; private ListView; private myadapter2 myadapter; public void onCreate (Bundle save) {super. onCreate (save); setContentView (R. layout. list); listview = (ListView) findViewById (R. id. listView1); Bundle bundle = listview. this. getIntent (). getExtras (); String date = null; String from_station = null; String to_station = null; date = bundle. getString ("date"); from_station = bundle. getString ("from_station"); to_station = bundle. getString ("to_station"); date = "2014-04-20"; // how can I leave a space when I do not know from_station = "HZH"; to_station = "CSQ"; params = new LinkedHashMap
(); Params. put (bookInfo. train_date, date); params. put (bookInfo. from_station, from_station); params. put (bookInfo. to_station, to_station); params. put ("purpose_codes", "ADULT"); data_set = new ArrayList
(); // Does the newly opened thread read information? /** Step 1 get the response object * Step 2 parse the data from response * // * getbook get = new getbook (bookInfo. get_book, params); * get. init (); String response = get. getreponse (); jsontest json = new jsontest (response); json. init (); data_set = json. get_data (); */String [] value = {"D105", "", "Changsha", "Hangzhou East ", "None", "yes", "125"}; LinkedHashMap
Map; for (int j = 0; j <3; j ++) {map = new LinkedHashMap (); for (int I = 0; I <9; I ++) {map. put (trainInfo. t_query [I], value [I]);} data_set.add (map);} myadapter = new myadapter2 (this, data_set); int size = data_set.size (); if (myadapter = null) Log. e ("adapter", "null"); Log. I ("size", "" + size); if (listview = null) Log. e ("listview", "null"); // if (size> 0) listview. setAdapter (myadapter); // data_set = main .} private class myadapter2 extends BaseAdapter {private Context context; private List
Data_set; private String [] id; public myadapter2 (Context context, List
Data) {this. context = context; this. data_set = data; id = new String [7]; for (int I = 0; I <= 5; I ++) id [I] = trainInfo. t_query [I]; id [6] = "seat";} public int getCount () {// TODO Auto-generated method stubreturn data_set.size ();} @ Overridepublic Object getItem (int I) {// TODO Auto-generated method stubreturn data_set.get (I) ;}@ Overridepublic long getItemId (int I) {// TODO Auto-generated method stubreturn I;} @ Overridepublic View getView (int I, View arg1, ViewGroup parant) {// TODO Auto-generated method stub/** "station_train_code", "arrive_time", "to_station_name", "from_station_name", "lishi", "start_time", "yw_num ", "yz_num", "wz_num" 7num */View v = arg1; if (v = null) {LayoutInflater m_layout = LayoutInflater. from (context); v = m_layout.inflate (R. layout. item, null);} LinkedHashMap
Map = data_set.get (I); TextView textview = null; String str = null; String seat = "seat"; textview = (TextView) v. findViewById (R. id. arrive_time); str = map. get ("arrive_time"); textview. setText (str); textview = (TextView) v. findViewById (R. id. lishi); textview. setText (map. get ("lishi"); textview = (TextView) v. findViewById (R. id. from_station_name); textview. setText (map. get ("from_station_name"); textview = (TextView) v. findViewById (R. id. start_time); textview. setText (map. get ("start_time"); textview = (TextView) v. findViewById (R. id. station_train_code); textview. setText (map. get ("station_train_code"); textview = (TextView) v. findViewById (R. id. to_station_name); textview. setText (map. get ("to_station_name"); str + = "hard seat:" + map. get ("yz_num") + "hard sleeper:" + map. get ("yw_num") + "no seat:" + map. get ("wz_num"); textview = (TextView) v. findViewById (R. id. seat); textview. setText (str); return v ;}}}