这是将微调项目用作发送电子邮件的输入的代码,但是我无法获取addStringParam
中的项目值。如何将微调器值作为字符串发送?我的API使用的是volleySingleton
。
String[] country = {
"India",
"USA",
"China",
"Japan",
"Other"
};
final Spinner spin = (Spinner) findViewById(R.id.spinner);
ArrayAdapter aa = new ArrayAdapter(this, android.R.layout.simple_spinner_item, country);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
spin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {@Override
public void onItemSelected(AdapterView < ?>parent, View view, int position, long id) {
String crustItem = spin.getSelectedItem().toString();
TextView displayTextView = (TextView) findViewById(R.id.displayTextView);
displayTextView.setText((String) parent.getItemAtPosition(position));
spin.setOnItemSelectedListener(this);
Object item = parent.getItemAtPosition(position);
}
@Override
public void onNothingSelected(AdapterView < ?>parent) {
}
});
String spintext = spin.getSelectedItem().toString().trim();
Textview massagetype = findViewById(R.id.book_massagetype);
bookNow = findViewById(R.id.book_button);
bookNow.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View v) {
boolean b = validateForm();
if (b) {
callingvolley();
}
}
});
}
// Use volley singleton for access api
private void callingvolley() {
String url = "http://massagebudget.com/app/webservices/api.php?apicall=booking";
SimpleMultiPartRequest simpleMultiPartRequest = new SimpleMultiPartRequest(Request.Method.POST, url, new Response.Listener < String > () {
// Access values in String format
;
simpleMultiPartRequest.addStringParam("massage_type", spintext.getText().toString());
simpleMultiPartRequest.addStringParam("message", message.getText().toString());
VolleySingleton.getInstance(this).addToRequestQue(simpleMultiPartRequest);
}
}