我有一个旋转器.
我想将用户输入值发送到PHP服务器.
我该怎么做客户端代码?
这是我的代码:
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 ampm;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的按钮
mPickTime作为单击打开TimePicker对话框的按钮
一个Spinner(spinner1)获取项目列表.
mDatedisplay显示用户在单击DatePickerDialog后编辑的日期.
mTimedisplay显示用户在单击TimePickerDialog后编辑的时间.
我希望DatePickerDialog,TimePickerDialog和spinner的用户输入的字符串值作为http post发送到服务器.请告诉我怎么做?我想要详细的代码.
解决方法 按照教程 here或 here进行 *** 作,您可能希望通过 Android Developer HTTP Post 总结以上是内存溢出为你收集整理的android – 如何向服务器发送HTTP POST请求请求全部内容,希望文章能够帮你解决android – 如何向服务器发送HTTP POST请求请求所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)