During the development of the project, the data of the checkbox in the form submitted to the background by the web is transmitted as an array, but we will encounter the following problems when we use the same interface to transmit data to the background on the mobile side .
1. How do I put an array in the Requestparams object to accept the background?
Workaround
for (int i = 0; i < array.size (); i++) {params.put ("content[" +i+ "]", Array.get (i));}
use loops to assemble numbers, note content["+i+"] This is a string type array when PHP background takes the content parameter
2. The array is uploaded to the background but the array may appear disorderly sequence phenomenon, timely testing did not occur also need to pay attention to, this is because requestparams inside the map structure of the stored parameters, map traversal out is unordered,
The workaround is to override the Requestparams class
Public class Myrequestparams extends requestparams{/** * */private static final long serialversionuid = 1L; Private ArrayList
list =null;public myrequestparams () {list =new ArrayList
();} @Overridepublic void put (string key, String value) {List.add (New Basicnamevaluepair (key, value));} @Overridepublic void put (String key, int value) {List.add (New Basicnamevaluepair (Key, string.valueof (value)));} @Overridepublic void put (String key, Long value) {List.add (New Basicnamevaluepair (Key, string.valueof (value)));} @Overrideprotected ArrayList
getparamslist () {return list;}}
The above describes the android to PHP background array types of parameters, including the contents of the content, I hope the PHP tutorial interested in a friend helpful.