大佬教程收集整理的这篇文章主要介绍了android – 如何向服务器发送HTTP POST请求请求,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的代码:
public class DineOutActivity extends Activity { private TextView mDateDisplay; private Button mPickDate; privatE int mYear; privatE int mMonth; privatE int mDay; /******************time picker**************/ private TextView mTimeDisplay; private Button mPickTime; privatE int mHour; privatE int mminute; privatE int mAmPm; static final int TIME_DIALOG_ID=1; static final int DATE_DIALOG_ID = 0; @Override public void onCreate(Bundle savedInstanceStatE) { super.onCreate(savedInstanceStatE); setContentView(R.layout.main); /********************spinner***********/ Spinner food = (Spinner) findViewById(R.id.spinner1); ArrayAdapter<CharSequence> foodadapter = ArrayAdapter.createFromresource( this,R.array.item_array,android.R.layout.simple_spinner_item); foodadapter.setDropDownViewresource(R.layout.spinner_layout); food.setAdapter(foodadapter); /**pick date*/ mDateDisplay = (TextView) findViewById(R.id.textView2); mTimeDisplay = (TextView) findViewById(R.id.textView4); mPickDate = (Button) findViewById(R.id.button2); /**pick time**/ mPickTime=(Button)findViewById(R.id.button3); // add a click listener to the button mPickTime.setOnClickListener(new View.onClickListener() { public void onClick(View v) { showDialog(TIME_DIALOG_ID); } }); // get the current time final Calendar c=Calendar.geTinstance(); mHour=c.get(Calendar.HOUR_OF_DAY); mminute=c.get(Calendar.minutE); mAmPm = c.get(Calendar.AM_PM); // display the current date upTimeDisplay(); /*****************************pick date***********************************/ // add a click listener to the button mPickDate.setOnClickListener(new View.onClickListener() { public void onClick(View v1) { showDialog(DATE_DIALOG_ID); } }); // get the current date final Calendar date = Calendar.geTinstance(); mYear = date.get(Calendar.YEAR); mMonth = date.get(Calendar.MONTH); mDay = date.get(Calendar.DAY_OF_MONTH); int mDst = date.get(Calendar.AM_PM); int mAmPm = date.get(Calendar.DST_OFFSET); // display the current date (this method is below) updateDisplay(); } // updates the date in the TextView private void upTimeDisplay() { // mTimeDisplay.setText(new // StringBuilder().append(pad(mHour)).append(":").append(pad(mminutE)).append(pad(mAmPm))); mTimeDisplay.setText(new StringBuilder().append(mHour).append(":").append(mminutE)); mTimeDisplay.setTextColor(R.color.green); } /** private Object pad(int mminute2) { if(mminute2>=10) return String.valueOf(mminute2); else return "0"+String.valueOf(mminute2); }**/ private TimePickerDialog.onTimeSetListener mtimeSetListener=new TimePickerDialog.onTimeSetListener() { public void onTimeSet(TimePicker view,int hourOfDay,int minutE) { mHour=hourOfDay; mminute=minute; int aR_808_11845@pm; upTimeDisplay(); } }; private void updateDisplay() { mDateDisplay.setText(new StringBuilder() // Month is 0 based so add 1 .append(mMonth + 1).append("-") .append(mDay).append("-") .append(mYear).append(" ")); mDateDisplay.setTextColor(R.color.green); // .append(mHour).append("_") // .append(mminutE).append("_"))); } // the callBACk received when the user "sets" the date in the dialog private DatePickerDialog.onDateSetListener mDateSetListener = new DatePickerDialog.onDateSetListener() { public void onDateSet(DatePicker view,int year,int monthOfYear,int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; updateDisplay(); } }; @Override protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this,mDateSetListener,mYear,mMonth,mDay); case TIME_DIALOG_ID: return new TimePickerDialog(this,mtimeSetListener,mHour,mminute,falsE); } return null; }
我使用mPickDate作为打开DatePickerDialog的按钮@H_727_2@mPickTime作为单击打开TimePicker对话框的按钮
一个Spinner(spinner1)获取项目列表.@H_727_2@mDateDisplay显示用户在单击DatePickerDialog后编辑的日期.@H_727_2@mTimeDisplay显示用户在单击TimePickerDialog后编辑的时间.
我希望DatePickerDialog,TimePickerDialog和spinner的用户输入的字符串值作为http post发送到服务器.请告诉我怎么做?我想要详细的代码.
以上是大佬教程为你收集整理的android – 如何向服务器发送HTTP POST请求请求全部内容,希望文章能够帮你解决android – 如何向服务器发送HTTP POST请求请求所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。