我正在編寫一個代碼,其中微調器由來自webservice的數據填充。我正在使用改造微調控件未在Android片段中顯示設置值
RestAdapter adapter = new RestAdapter.Builder().setEndpoint(InterfaceApi.URL).build();
InterfaceApi interfaceApi = adapter.create(InterfaceApi.class);
interfaceApi.getAdminLeaveTypes(new Callback<ArrayList<AdminLeaveTypeBeans>>() {
@Override
public void success(ArrayList<AdminLeaveTypeBeans> adminLeaveTypeBeanses, Response response) {
if (adminLeaveTypeBeanses.isEmpty()) {
Toast.makeText(getActivity(), "No record found", Toast.LENGTH_SHORT).show();
} else {
for (int i = 0; i < adminLeaveTypeBeanses.size(); i++) {
leaveTypeId.add(i, adminLeaveTypeBeanses.get(i).getTypeId());
leaveTypeName.add(i, adminLeaveTypeBeanses.get(i).getTypeName());
}
}
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(getActivity(), "Error..may be webservice not running", Toast.LENGTH_SHORT).show();
Log.e("failure: ", "messgae" +error.getMessage());
}
});
ArrayAdapter<String> adapterLeaveType = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1, leaveTypeName);
spinnerLeaveAdminType.setAdapter(adapterLeaveType);
我期待在選擇後將值設置爲spinner.Any幫助將不勝感激。由於