を使用してHTTP Serverに整数を送信:私はこの<code>NameValuePair</code>方法使用して、私のAndroidのクライアントからWebサーバへの値のカップルを送信したいのNameValuePair
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http:/xxxxxxx");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
String amount = paymentAmount.getText().toString();
String email = inputEmail.getText().toString();
nameValuePairs.add(new BasicNameValuePair("donationAmount", amount));
nameValuePairs.add(new BasicNameValuePair("email", email));
nameValuePairs.add(new BasicNameValuePair("paymentMethod", "5"));
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
}
}
残念ながらNameValuePair
は私がする必要がある、唯一の文字列を送信することができますInteger値も送信します。誰も私の問題を解決するために私を助けることができますか?
私は、a、b、c、d、e、fiのような異なる名前のスピナーで5つの値を持っています。この文字列値の整数値を渡したいのですがどうすればいいでしょうか? <項目値= "1"> <項目値= "2"> B <項目値= "3"> C <項目値= "4"> D <項目値= "5 "> - f
string-array> –
@AdityaVyas、新しい投稿で新しい質問をしてください。 –
スピナーから選択された価値を得ることだけです。次に、Integer.toString()メソッドを使用してIntegerをStringに変換できます。 @DarylBennettあなたの質問はこのスレッドに関連していません。 –