JSON的问题后在旋转一个显示它:
{
"offer_detail":[
{
"movieid":"72",
"date_value":"2014-05-11",
"showtime":[
"10:30 AM",
"2:30 PM",
"6:30 PM",
"9:30 PM"
],
"screen_no":"SCREEN 2",
"id":"186"
}
],
"success":1,
"message":"Successfully found "
}
我试图显示与欣欣相应时间 一个微调的前内 - 10:30 下午2:30 6:30 PM 9:30 PM
但在我的情况下,它显示整个showtime数组,而不是分别显示时间。
而这正是我已经试过:
c = JSONfunctions
.getJSONfromURL("http://192.168.1.104/OnlineTicketBooking/book_now1.php?movieid='72'");
try {
JSONArray jarray = c.getJSONArray("offer_detail");
ArrayList xyz= new ArrayList();
for(int i = 0; i < jarray.length(); i++){
c = jarray.getJSONObject(i);
xyz.add(c.getString("showtime"));
Log.d("get value",c.getString("showtime"));
}
。
ArrayAdapter dataAdapter1 = new ArrayAdapter(Booking.this, android.R.layout.simple_spinner_item,xyz);
dataAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(dataAdapter1);
String cl=spin.getSelectedItem().toString();
String filenameArray[] = cl.split(",");
int size = filenameArray.length;
Log.d("count",""+size);
ArrayList nw = new ArrayList();
for (int j = 0; j < filenameArray.length; j++) {
JSONObject c = jarray.getJSONObject(j);
nw.add(c.getString("showtime"));
Log.d("getvalue",c.getString("showtime"));
}
ArrayAdapter dataAdapter2 = new ArrayAdapter(Booking.this, android.R.layout.simple_spinner_item,nw);
dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(dataAdapter2);
spin.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), spin.getSelectedItem().toString(),
Toast.LENGTH_SHORT).show();
String cl=spin.getSelectedItem().toString();
Log.d("classname",cl);
}
public void onNothingSelected(AdapterView> arg0) {
// TODO Auto-generated method stub
}
});
}
谢谢。