如何在服务器中显示微调器中保存的值?

时间:2016-07-15 06:29:02

标签: android soap spinner

以下是我的服务器响应

  

[{" METER_SERIAL_NO":5," account_no上":58889" KNO_NUMBER":57970099775448" CONSUMER_NAME":&#34 ; Nirmal chauhan"," ADDRESS1":" Udaipur Ra​​jasthan"," TELEPHONE_NO":9983835101," MOBILE_NO":9983835101,& #34; SANC_LOAD":8877," TEST_TYPE":" 0"" COMPLAINT_NO":17448" CIRCLE":1, " DIVISION":3," SUBDIVISION":9," TEST_NO":1884," ACCUCHECK_NO":588," FATHER_NAME&# 34;:" Arjun lal"," EXCEPTION_REMARK":" Fjdajjdcaacvb"," METER_MAKE":null," METER_CONSTANT" :空," CURRENT_READING":空," PHASE_TYPE":空," METER_TYPE":空," METER_BOX_STATUS":空,&#34 ; METER_TERMINAL_COVER":空," METER_PUSH_FIT":空," PUST_FIT":空," METER_TERMINAL_BLOCK":空," METER_DIGITAL_VISIBLE&#34 ;:空," METER_FIGURES_UPSET":空," METER_DIGITS_CHANGING":空," SL_TYPE":空," SL_ANYJOINT&#34 ;:空," SL_COMMUNICATIONPORT":空," SL_MTRLOCATION":空," LI_EARTHLEAKAGEIND":空," LI_REVERSELOADIND":空,&# 34; LI_BLINKINGOFLED":空," SEAL_EXISTINGSTATUSMTRBOX":空," SEAL_EXISTINGMTRBODY":空," SEAL_EXISTINGTERMCOVER":空," NEWSEALNO_MTRBOX" :空," NEWSEALNO_MTRBODY":空," VERIFIED_BY":空," POST":空," CONSUMER_REMARK":空,&#34 ; CERTIFICATION_NO":空," DUE_CALIBRATIONDATE":空," THREEPHASE_RPHASE":空," MTR_DISPLAY":空," MTR_DISPLAYLOAD&#34 ;:空}

我的Spinner中有下面的硬编码数组列表

String[] testTypeArray ={"None","Normal Testing","Emergency Testing"};

下面是我的微调器适配器

 public void SpinnerValues(){
        ArrayAdapter adapterrelation = new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, testTypeArray);
        spnTestType.setAdapter(adapterrelation);
        spnTestType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
                // TODO Auto-generated method stub
                testType = spnTestType.getSelectedItem().toString();

            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }

        });

    }

一切都很好。列表在我的微调器中显示完美。现在我想要的是,如果&#34; 0&#34;来自我的服务器然后它的节目&#34;无&#34;选择。如果&#34; 1&#34;然后它的节目&#34;正常测试&#34;选定的。我怎样才能做到这一点?

我在EditText中显示所有其他值。首先,来自服务器的所有数据显示在所有元素中,然后用户查看数据并从最新的数据更新他的数据。然后按提交按钮,然后所有数据也将在服务器上更新。

2 个答案:

答案 0 :(得分:0)

您可以使用spinner.setSelection(position)

if(server_result.equals("0"))
{
   your_spinner.setSelection(0);
}
else if(server_result.equals("1"))
{
   your_spinner.setSelection(1);
}
else if(server_result.equals("2"))
{
   your_spinner.setSelection(2);
}
.
.
.

这应该对你有帮助。

答案 1 :(得分:0)

试试这个:

spnTestType.setSelected(Integer.parseInt(serverResponse));