我要将POST
微调器的值传递给数据库
遗憾的是,我不知道如何在CODE的任何部分实现POST
方法。
我在发送Snipper值方面遇到了问题。
public class FormActivity extends AppCompatActivity implements
....
spinnerStudy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String all_study = spinnerStudy.getItemAtPosition(spinnerStudy.getSelectedItemPosition()).toString();
if(!Objects.equals(all_study, "")){
Toast.makeText(getApplicationContext(),all_study, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// DO Nothing here
}
});
spinnerCity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String all_city = spinnerCity.getItemAtPosition(spinnerCity.getSelectedItemPosition()).toString();
if(!Objects.equals(all_city, "")) {
Toast.makeText(getApplicationContext(), all_city, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// DO Nothing here
}
});
s
pinnerUniversity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String all_university = spinnerUniversity.getItemAtPosition(spinnerUniversity.getSelectedItemPosition()).toString();
if(!Objects.equals(all_university, "")) {
Toast.makeText(getApplicationContext(), all_university, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// DO Nothing here
}
});
spinnerUnited.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String all_united = spinnerUnited.getItemAtPosition(spinnerUnited.getSelectedItemPosition()).toString();
if(!Objects.equals(all_united, "")) {
Toast.makeText(getApplicationContext(), all_united, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// DO Nothing here
}
});
button.setOnClickListener(this);
...
请帮助我......在这个案例中,post方法如何发送参数? 如何从Spinner获得一个公共字符串?谢谢大家
答案 0 :(得分:2)
mySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//position is spinner position
//mySpinner.getSelectedItem().toString(); IS value of position (string)
mMap.put("your Key",mySpinner.getSelectedItem().toString());
//the value add to map of volley
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});