Привет в приведенном ниже коде содержит счетчик, названный как Тип собственности, который содержит список строк в этом ответе от сервера. Я устанавливаю эти значения в счетчик.
Но он не устанавливает никаких значений в Спиннер может помочь мне решить эту проблему.
Опишите. java:
private void describe() {
sessionId = getActivity().getIntent().getStringExtra("sessionId");
String operation = "describe";
String module="Accounts";
final GetNoticeDataService service = RetrofitInstance.getRetrofitInstance().create(GetNoticeDataService.class);
/** Call the method with parameter in the interface to get the notice data*/
Call<AccountDescribe> call = service.AccountDescribe(operation, sessionId, module);
/**Log the URL called*/
Log.i("URL Called", call.request().url() + "");
call.enqueue(new Callback<AccountDescribe>() {
@Override
public void onResponse(Call<AccountDescribe> call, Response<AccountDescribe> response) {
Log.e("response",new Gson().toJson(response.body()));
if (response.isSuccessful()) {
Log.e("response",new Gson().toJson(response.body()));
AccountDescribe accountDescribe = response.body();
String success = accountDescribe.getSuccess();
if (success.equals("true")) {
Results_Account results=accountDescribe.getResult();
//
//
// //parse describe details
DescribeDetails describeDetails = results.getDescribe();
String label = describeDetails.getLabel();
String name=describeDetails.getName();
//parse fields details
TypeValues typeValues=null;
ArrayList<FieldDetails> fields = describeDetails.getFields();
// Log.e("fields", String.valueOf(fields));
//parse fields information
for(FieldDetails field: fields) {
String fieldName = field.getName();
String fieldLabel = field.getLabel();
typeValues=field.getType();
}
ArrayList<PickListValues> pickListValues=typeValues.getPicklistValues();
for(PickListValues pickListValues1: pickListValues) {
String pick_label = pickListValues1.getLabel();
String pick_value = pickListValues1.getValue();
//String[] values=pick_value.toString();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, pick_value);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
}
}
}
}
@Override
public void onFailure(Call<AccountDescribe> call, Throwable t) {
Log.d("error",t.getMessage());
}
});
AccountDescribe. java:
public class AccountDescribe {
@SerializedName("success")
private String success;
@SerializedName("result")
private Results_Account result;
public Results_Account getResult() {
return result;
}
public void setResult(Results_Account result) {
this.result = result;
}
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
}
Results_Account. java:
public class Results_Account {
@SerializedName("describe")
@Expose
private DescribeDetails describe;
public DescribeDetails getDescribe() {
return describe;
}
public void setDescribe(DescribeDetails describe) {
this.describe = describe;
}
}
DescribeDetails. java:
public class DescribeDetails {
@SerializedName("label")
@Expose
private String label;
@SerializedName("name")
@Expose
private String name;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCreateable() {
return createable;
}
public void setCreateable(String createable) {
this.createable = createable;
}
public String getUpdateable() {
return updateable;
}
public void setUpdateable(String updateable) {
this.updateable = updateable;
}
public String getDeleteable() {
return deleteable;
}
public void setDeleteable(String deleteable) {
this.deleteable = deleteable;
}
public String getRetrieveable() {
return retrieveable;
}
public void setRetrieveable(String retrieveable) {
this.retrieveable = retrieveable;
}
@SerializedName("createable")
@Expose
private String createable;
@SerializedName("updateable")
@Expose
private String updateable;
@SerializedName("deleteable")
@Expose
private String deleteable;
@SerializedName("retrieveable")
@Expose
private String retrieveable;
@SerializedName("fields")
@Expose
private ArrayList<FieldDetails> fields;
public ArrayList<FieldDetails> getFields() {
return fields;
}
public void setFields(ArrayList<FieldDetails> fields) {
this.fields = fields;
}
}
FieldDetails. java:
public class FieldDetails {
@SerializedName("name")
@Expose
private String name;
@SerializedName("label")
@Expose
private String label;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getMandatory() {
return mandatory;
}
public void setMandatory(String mandatory) {
this.mandatory = mandatory;
}
public TypeValues getType() {
return type;
}
public void setType(TypeValues type) {
this.type = type;
}
@SerializedName("mandatory")
@Expose
private String mandatory;
@SerializedName("type")
@Expose
private TypeValues type;
}
TypeValues. java:
public class TypeValues {
@SerializedName("picklistValues")
@Expose
private ArrayList<PickListValues> picklistValues;
public ArrayList<PickListValues> getPicklistValues() {
return picklistValues;
}
public void setPicklistValues(ArrayList<PickListValues> picklistValues) {
this.picklistValues = picklistValues;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@SerializedName("defaultValue")
@Expose
private String defaultValue;
@SerializedName("name")
@Expose
private String name;
}
PickListValues. java:
public class PickListValues {
@SerializedName("label")
@Expose
private String label;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@SerializedName("value")
@Expose
private String value;
}
ответ:
{
"success": true,
"result": {
"describe": {
"label": "Accounts",
"name": "Accounts",
"createable": true,
"updateable": true,
"deleteable": true,
"retrieveable": true,
"fields": [
{
"name": "accountname",
"label": "Account Name",
"mandatory": true,
"type": {
"name": "string"
},
"isunique": true,
"nullable": false,
"editable": true,
"default": "",
"headerfield": "0",
"summaryfield": "1"
},
{
"name": "account_no",
"label": "Account Number",
"mandatory": false,
"type": {
"name": "string"
},
"isunique": false,
"nullable": false,
"editable": false,
"default": "",
"headerfield": "0",
"summaryfield": "0"
},
{
"name": "phone",
"label": "Landline",
"mandatory": false,
"type": {
"name": "phone"
},
"isunique": false,
"nullable": true,
"editable": true,
"default": "",
"headerfield": "1",
"summaryfield": "0"
},
{
"name": "website",
"label": "Website",
"mandatory": false,
"type": {
"name": "url"
},
"isunique": false,
"nullable": true,
"editable": true,
"default": "",
"headerfield": "0",
"summaryfield": "0"
},
{
"name": "email1",
"label": "Primary Email",
"mandatory": false,
"type": {
"name": "email"
},
"isunique": false,
"nullable": true,
"editable": true,
"default": "",
"headerfield": "0",
"summaryfield": "0"
},
{
"name": "ownership",
"label": "GST Number",
"mandatory": false,
"type": {
"name": "string"
},
"isunique": false,
"nullable": true,
"editable": true,
"default": "",
"headerfield": "0",
"summaryfield": "0"
},
{
"name": "rating",
"label": "Facility Type",
"mandatory": true,
"type": {
"picklistValues": [
{
"label": "Individual",
"value": "Individual"
},
{
"label": "Corporate Chain Hospital",
"value": "Corporate Chain Hospital"
},
{
"label": "Institution",
"value": "Institution"
},
{
"label": "Maternity Home",
"value": "Maternity Home"
},
{
"label": "Other",
"value": "Other"
},
{
"label": "Hospital",
"value": "Hospital"
},
{
"label": "Dealer",
"value": "Dealer"
},
{
"label": "Multispeciality Hospital",
"value": "Multispeciality Hospital"
},
{
"label": "Corporate Chain Diagnostic Center",
"value": "Corporate Chain Diagnostic Center"
},
{
"label": "Nursing Home",
"value": "Nursing Home"
},
{
"label": "Diagnostic Center",
"value": "Diagnostic Center"
},
{
"label": "Clinic",
"value": "Clinic"
},
{
"label": "Clinical Laboratory",
"value": "Clinical Laboratory"
}
],
"defaultValue": "Individual",
"name": "picklist"
},
"isunique": false,
"nullable": true,
"editable": true,
"default": "",
"headerfield": "0",
"summaryfield": "0"
},
{
"name": "industry",
"label": "Ownership Type",
"mandatory": true,
"type": {
"picklistValues": [
{
"label": "Proprietor",
"value": "Proprietor"
},
{
"label": "Partnership",
"value": "Partnership"
},
{
"label": "Pvt Ltd",
"value": "Pvt Ltd"
},
{
"label": "Trust",
"value": "Trust"
},
{
"label": "Society",
"value": "Society"
},
{
"label": "Foundation",
"value": "Foundation"
},
{
"label": "Hospital",
"value": "Hospital"
},
{
"label": "Private Clinic",
"value": "Private Clinic"
},
{
"label": "LLP",
"value": "LLP"
},
{
"label": "Limited",
"value": "Limited"
}
],
"defaultValue": "Proprietor",
"name": "picklist"
},
"isunique": false,
"nullable": true,
"editable": true,
"default": "",
"headerfield": "0",
"summaryfield": "0"
},
}
}
}