请你告诉我为什么我的arraylist没有加载到微调器中。它显示空Spinner.im以使用arraylist填充微调器,并进行服务调用; 我在哪里做错了。 这是我的活动;
public class CircleListActivity extends MWTActivity {
private ArrayList<String> arrayList = new ArrayList<String>();
private Spinner state_spinner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, MWT.Home_SCREEN);
setContentView(R.layout.circlelist);
showDialog(1);
MWTWebService.circlelistServices(new IMWTListener() {
@Override
public void recieveVersionResponse(String resp) {
}
@Override
public void receivedResponse(String resp, String id) {
}
@Override
public void receivedResponse(String resp) {
showDialog(1);
System.out.println("rsp: " + resp);
try {
JSONObject jsonObject = new JSONObject(resp);
JSONArray jsonArray = jsonObject
.getJSONArray("circleListForHording");
arrayList.add("Select State");
for (int i = 0; i < jsonArray.length(); i++) {
String state = (String) jsonArray.get(i);
arrayList.add(state);
}
state_spinner = (Spinner) findViewById(R.id.state);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
CircleListActivity.this,
android.R.layout.simple_spinner_item, arrayList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
System.out.println("PP " + adapter.getItem(1));
state_spinner.setAdapter(adapter);
dismissDialog(1);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(String resp, int erroCode) {
}
}, LoginScreen.userNameNew.toString().trim());
// if (Util.readNetworkConnection(CircleListActivity.this)) {} else {
// ArrayAdapter<String> adapter = new ArrayAdapter<String>(
// CircleListActivity.this,
// android.R.layout.simple_spinner_item, arrayList);
//
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// state_spinner.setAdapter(adapter);
//
// }
}
}