こんにちは私は、textView要素を使用してhttpリクエストを送信する方法を知りたいアンドロイドアプリを作成しています。textView要素を使用してhttpリクエストを送信する方法
編集可能でないtextViewの別のアクティビティに夏が表示されたforを作成しました。
私は次のコードを編集して、http要求コードを追加しました。これで、名前、タイプ、アクションなどのパラメータを追加する必要があることを知りたいと思います。私は混乱し、私はそれらここにコード
public void sendData(){
nameText =(TextView)findViewById(R.id.content);
viewDateText =(TextView)findViewById(R.id.showDate);
viewEmailText=(TextView)findViewById(R.id.showEmail);
viewMobileText=(TextView)findViewById(R.id.showMobileNumber);
viewTotalAdultText = (TextView)findViewById(R.id.showTotalAdults);
ViewTotalChildren =(TextView)findViewById(R.id.showTotalChildrens);
viewChildAge =(TextView)findViewById(R.id.showChildrensAge);
viewTotalRoomsText =(TextView)findViewById(R.id.showTotalRooms);
viewDepartureText =(TextView)findViewById(R.id.showDepartureCity);
viewDeatinationText =(TextView)findViewById(R.id.showDestination);
viewDaysText =(TextView)findViewById(R.id.showTotalDays);
viewBudgetText =(TextView)findViewById(R.id.showBudget);
viewPreferHotelText =(TextView)findViewById(R.id.showHotelPreferance);
viewAirticketText =(TextView)findViewById(R.id.showAirticketRequired);
viewIntercityText = (TextView)findViewById(R.id.showIntercityTravel);
viewTravelTypeText = (TextView)findViewById(R.id.showTraveType);
viewMealText =(TextView)findViewById(R.id.showMealPlan);
viewInfoText = (TextView)findViewById(R.id.showAdditionalInfo);
nameText.getText().toString();
viewDateText.getText().toString();
viewEmailText.getText().toString();
viewMobileText.getText().toString();
viewTotalAdultText.getText().toString();
ViewTotalChildren.getText().toString();
viewChildAge.getText().toString();
viewTotalRoomsText.getText().toString();
viewDepartureText.getText().toString();
viewDeatinationText.getText().toString();
viewDaysText.getText().toString();
viewBudgetText.getText().toString();
viewPreferHotelText.getText().toString();
viewAirticketText.getText().toString();
viewIntercityText.getText().toString();
viewTravelTypeText.getText().toString();
viewMealText.getText().toString();
viewInfoText.getText().toString();
submitData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost("http://routern.com/EldestinoAction");
String json = "";
try{
JSONObject jsonObject = new JSONObject();
jsonObject.put("nameText",nameText);
jsonObject.put("date",viewDateText);
jsonObject.put("Email",viewEmailText);
jsonObject.put("mobile",viewMobileText);
jsonObject.put("Totaladult",viewTotalAdultText);
jsonObject.put("totalchildren",ViewTotalChildren);
jsonObject.put("childrenAge",viewChildAge);
jsonObject.put("hotelRooms",viewTotalRoomsText);
jsonObject.put("departure",viewDepartureText);
jsonObject.put("destination",viewDeatinationText);
jsonObject.put("days",viewDaysText);
jsonObject.put("budget",viewBudgetText);
jsonObject.put("preferhotel",viewPreferHotelText);
jsonObject.put("flight",viewAirticketText);
jsonObject.put("intercity",viewIntercityText);
jsonObject.put("travelType",viewTravelTypeText);
jsonObject.put("meal",viewMealText);
jsonObject.put("info",viewInfoText);
json = jsonObject.toString();
StringEntity se = new StringEntity(json);
post.setEntity(se);
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
httpclient.execute(post);
}catch (Exception e){
e.printStackTrace();
}
}
});
}
を次のようにhttpリクエストコードは私が名前などのパラメータを追加する必要があることは知られたくあり追加、タイプに適用していますどのように実際にそれを取得しておりません私は実際に私はここでそれらのコードを適用している方法を取得していない私は混乱して取得するいくつかの例を通過したアクション
あなたがHTTPリクエストを試してみたのは何ですか? [HttpUrlConnection](https://developer.android.com/reference/java/net/HttpURLConnection.html)が見えましたか?あなたは18時間前に作成された同じ質問をここに持っています:[私が知りたいと思ったことについて、データをテキストから読む方法について](http://stackoverflow.com/questions/38252826/i-テキストからデータを読む方法についての情報を得たいと思っています)。申し訳ありませんが、あなたがまだ何も検索していないため、私はあなたにマイナスポイントを与えます。もしあなたがgoogleを検索して**アンドロイドを探して、httpリクエストをする方法**があれば、多くの例が得られます。 –
検索せずに検索しました。私はここに投稿しません。 – Moulick
okeyなぜあなたは同じ質問を作成したのですか?以前の質問を編集できます。マイナス点があるので、私はあなたのためにそれを言っています。 –