java - Submit data to MySQL database from android app -
java - Submit data to MySQL database from android app -
i'm trying write form create reservation , save mysql. there 4-5 field in form name, phone, email, comment, time, date, table, people
. must tell i'm new in java , android , don't know how i'm trying. think code mess right need help. here code far of reservation.java
public class reservation extends activity implements onclicklistener { string name; string email; string phone; string comment; string datetime; string time; string table; string numberofpeople; private edittext edittext1, edittext3, edittext2, edittext4, txtdate, txttime; private button btncalendar, btntimepicker, btnmenues; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.reservation); edittext1 = (edittext) findviewbyid(r.id.edittext1); edittext3 = (edittext) findviewbyid(r.id.edittext3); edittext2 = (edittext) findviewbyid(r.id.edittext2); edittext4 = (edittext) findviewbyid(r.id.edittext4); txtdate = (edittext) findviewbyid(r.id.txtdate); txttime = (edittext) findviewbyid(r.id.txttime); btncalendar = (button) findviewbyid(r.id.btncalendar); btntimepicker = (button) findviewbyid(r.id.btntimepicker); btnmenues = (button) findviewbyid(r.id.btnmenues); btnmenues.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { name = edittext1.gettext().tostring(); phone = edittext3.gettext().tostring(); email = edittext2.gettext().tostring(); comment = edittext4.gettext().tostring(); datetime = txtdate.gettext().tostring(); datetime = txttime.gettext().tostring(); new summaryasynctask().execute((void) null); } }); } class summaryasynctask extends asynctask<void, void, boolean> { private void postdata(string name, string email, string phone, string comment, string date, string table, string numberofpeople) { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://link.to.server.com/savereservation.php"); seek { arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(4); namevaluepairs.add(new basicnamevaluepair("name", name)); namevaluepairs.add(new basicnamevaluepair("email", email)); namevaluepairs.add(new basicnamevaluepair("phone", phone)); namevaluepairs.add(new basicnamevaluepair("comment", comment)); namevaluepairs.add(new basicnamevaluepair("date", date)); namevaluepairs.add(new basicnamevaluepair("table", table)); namevaluepairs.add(new basicnamevaluepair("numberofpeople", numberofpeople)); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); } catch(exception e) { log.e("log_tag", "error: "+e.tostring()); } } @override protected boolean doinbackground(void... params) { postdata(name, email, phone, comment, datetime, time, table ); homecoming null; } } }
currently error is
the type reservation must implement inherited abstract method view.onclicklistener.onclick(view) update:
and how save date , time in database in 1 row or two? if 1 row how create in android side?
udpate2: how implement btncalendar, btntimepicker
have them in reservation.xml
, in form. must implement date , time picker in code?
you implements onclicklistener
not on ride onclick(view view)
method of onclicklistener interface mandatory. please override method first , remove on click listener
oncreate
method.
see below link more information:-
https://anujarosha.wordpress.com/2011/11/13/how-to-implements-onclicklistener-for-a-view-item-in-android/
java php android mysql
Comments
Post a Comment