如何将微调器值设置为null

时间:2014-11-05 10:46:30

标签: java android

我有一个微调器,然后我想将第一个值设置为null。我将获得itemselected的值然后发送到网址。我的问题是即使我没有点击它有价值。 这是我的微调器:

  public void addListenerOnSpinnerItemSelection() {
    spinner1 = (Spinner) findViewById(R.id.spinner1);
    spinner2 = (Spinner) findViewById(R.id.spinner2);
    spinner3 = (Spinner) findViewById(R.id.spinner3);
    spinner4 = (Spinner) findViewById(R.id.spinner4);
spinner1 = (Spinner) findViewById(R.id.spinner1);
spinner1.setOnItemSelectedListener(new MyOnItemSelectedListener());
spinner2 = (Spinner) findViewById(R.id.spinner2);
spinner2.setOnItemSelectedListener(new MyOnItemSelectedListener());
spinner3 = (Spinner) findViewById(R.id.spinner3);
spinner3.setOnItemSelectedListener(new MyOnItemSelectedListener());
spinner4 = (Spinner) findViewById(R.id.spinner4);
spinner4.setOnItemSelectedListener(new MyOnItemSelectedListener());

}  这是我的帖子:

         public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("");
try {
    // Add your data

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new        BasicNameValuePair("dateSched",sharedpreferences.getString("currentdate", "currentdate")));
    nameValuePairs.add(new BasicNameValuePair("WeddingStyle", String.valueOf(spinner2.getSelectedItem())));
    nameValuePairs.add(new BasicNameValuePair("ColorMotif", String.valueOf(spinner3.getSelectedItem())));
    nameValuePairs.add(new BasicNameValuePair("LocationType", String.valueOf(spinner4.getSelectedItem())));
    nameValuePairs.add(new BasicNameValuePair("WeddingFlower", String.valueOf(spinner1.getSelectedItem())));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    // Execute HTTP Post Request
  HttpResponse response = httpclient.execute(httppost);

} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
} catch (IOException e) {
    // TODO Auto-generated catch block
}
} 

0 个答案:

没有答案