[英]Sending hidden form filed to server
I want to implement one spinner where data will come from strings.xml
file and when I click on update button then the hidden key will save on server.我想实现一个微调器,其中数据将来自strings.xml
文件,当我单击更新按钮时,隐藏键将保存在服务器上。 Below is my code where I am sending integer value but I need to send:下面是我发送整数值但我需要发送的代码:
{(Select,""),(None,"none"),(Learing Impaired,"Learing_Impaired"),etc} {(Select,""),(None,"none"),(Learing Impaired,"Learing_Impaired"),etc}
How can we do this in my app?我们如何在我的应用程序中执行此操作?
final List<String> list2 = Arrays.asList(getResources().getStringArray(R.array.scases));
final List<KeyPairBoolData> listArray2 = new ArrayList<>();
for (int j = 0; j < list2.size(); j++) {
KeyPairBoolData h1 = new KeyPairBoolData();
h1.setId(j + 1);
h1.setName(list2.get(j));
h1.setSelected(false);
listArray2.add(h1);
specialCaseSpinner.setItems(listArray2, -1, new SpinnerListener() {
@Override
public void onItemsSelected(List<KeyPairBoolData> items) {
for (int j = 0; j < items.size(); j++) {
if (items.get(j).isSelected()) {
// Log.i(getTag(), i + " : " + items.get(i).getName() + " : " + items.get(i).isSelected());
Log.e("spinner.........",items.get(j).getName() + " : " + items.get(j).isSelected());
}
}
}
});
}
Below is the string array name下面是字符串数组名称
<string-array name="scases">
<item>Select</item>
<item>none</item>
<item>Learing Impaired</item>
<item>Speach impaired</item>
<item>Dyslexic</item>
<item>blind</item>
<item>Polio affilicted</item>
<item>visually challenged</item>
<item>others</item>
</string-array>
Finally I have done this, In my code, Occupation is a string array where I have defined the hidden value which will store on server but not show on spinner items and then set the id of occupation h.setId(Occupation[i]);最后我做到了这一点,在我的代码中,Occupation 是一个字符串数组,其中我定义了将存储在服务器上但不显示在微调项上的隐藏值,然后设置职业的 id h.setId(Occupation[i]);
String[] Occupation = {"rest_all", "Government", "Officer", "Merchant", "Shipping", "Professor", "Teacher", "Doctor",
"Dentist", "Chartered Accountant", "Cost Accountant", "Engineer", "Software", "Educationist", "Business",
"Civil Services", "Management"};
final List<String> list4 = Arrays.asList(getResources().getStringArray(R.array.Occupation));
final List<KeyPairBoolData> listArray4 = new ArrayList<>();
for (int i = 0; i < list4.size(); i++) {
KeyPairBoolData h = new KeyPairBoolData();
h.setId(Occupation[i]);
h.setName(list4.get(i));
h.setSelected(false);
listArray4.add(h);
occupationSpinner.setItems(listArray4, -1, new SpinnerListener() {
@Override
public void onItemsSelected(List<KeyPairBoolData> items) {
for (int i = 0; i < items.size(); i++) {
if (items.get(i).isSelected()) {
// Log.i(getTag(), i + " : " + items.get(i).getName() + " : " + items.get(i).isSelected());
Log.e("spinner.........", items.get(i).getId() + " : " + items.get(i).isSelected());
}
}
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.