java - Android incoming and outgoing server setting -
i started develop email application. created screens.. got stuck on "incoming server setting screen". problem how check incoming , outgoing server setting.
my code page layout is,
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="fill_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" tools:context=".incomingsetting" > <textview android:id="@+id/tvprotocol" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:text="protocol" /> <spinner android:id="@+id/spnprotocol" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_below="@+id/tvprotocol" /> <textview android:id="@+id/tvpassword" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/etusername" android:layout_below="@+id/etusername" android:text="password" /> <button android:id="@+id/bback" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:text="<= back" /> <button android:id="@+id/bnext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:text="next =>" /> <edittext android:id="@+id/etport" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/bback" android:layout_alignleft="@+id/bback" android:ems="10" android:inputtype="number" /> <textview android:id="@+id/tvport" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/etport" android:layout_alignleft="@+id/etport" android:text="server port" /> <edittext android:id="@+id/etemail" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/tvemail" android:layout_below="@+id/tvemail" android:ems="10" android:inputtype="textemailaddress" /> <textview android:id="@+id/tvusername" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/etemail" android:layout_below="@+id/etemail" android:text="username" /> <edittext android:id="@+id/etusername" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/etserver" android:layout_below="@+id/tvusername" android:ems="10" android:inputtype="textemailaddress" /> <edittext android:id="@+id/etpassword" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/tvpassword" android:layout_below="@+id/tvpassword" android:ems="10" android:inputtype="textpassword" /> <textview android:id="@+id/tvserver" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/etpassword" android:layout_below="@+id/etpassword" android:text="server" /> <edittext android:id="@+id/etserver" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/spnsecurity" android:layout_below="@+id/tvserver" android:ems="10" android:hint="server full name"/> <textview android:id="@+id/tvemail" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/spnprotocol" android:layout_below="@+id/spnprotocol" android:text="email address" /> <spinner android:id="@+id/spnsecurity" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/tvport" android:layout_alignleft="@+id/tvport" /> <textview android:id="@+id/tvseurity" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/etserver" android:layout_below="@+id/etserver" android:text="security type" /> </relativelayout>
i created class server coding dont know how interact server. java class this.
public class incomingsetting extends activity implements onclicklistener { spinner ddprotocol, ddsecurity; string[] items_protocol = new string[]{"pop3", "imap", "exchange"}; string[] items_security = new string[]{"none", "non-ssl","ssl", "ssl (accept certificate)"}; arrayadapter<string> adapter_protocol, adapter_security; textview tvprotocol, tvemail, tvpass, tvusername; textview tvserver, tvport, tvsecurity; edittext etemail, etusername, etpass, etserver, etport; button btnext, btback; string uristring1, uristring2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.incomingsetting); intent = getintent(); uristring1 = i.getstringextra("email"); uristring2 = i.getstringextra("password"); // bundle extras = getintent().getextras(); //uristring1 = extras.getstring("email"); //uristring1 = extras.getstring("password"); initialize(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.incomingsetting, menu); return true; } private void initialize() { // todo auto-generated method stub ddprotocol = (spinner)findviewbyid(r.id.spnprotocol); ddsecurity = (spinner)findviewbyid(r.id.spnsecurity); adapter_protocol = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, items_protocol); adapter_security = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, items_security); ddprotocol.setadapter(adapter_protocol); ddsecurity.setadapter(adapter_security); ddprotocol.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(adapterview<?> adapter, view v, int position, long id) { // on selecting spinner item string item = adapter.getitematposition(position).tostring(); // showing selected spinner item toast.maketext(getapplicationcontext(), "protocol:: " + item, toast.length_long).show(); } @override public void onnothingselected(adapterview<?> arg0) { // todo auto-generated method stub } }); ddsecurity.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(adapterview<?> adapter, view v, int position, long id) { // on selecting spinner item string item = adapter.getitematposition(position).tostring(); // showing selected spinner item toast.maketext(getapplicationcontext(), "protocol:: " + item, toast.length_long).show(); } @override public void onnothingselected(adapterview<?> arg0) { // todo auto-generated method stub } }); btnext =(button)findviewbyid(r.id.bnext); btback=(button)findviewbyid(r.id.bback); etemail = (edittext)findviewbyid(r.id.etemail); etpass = (edittext)findviewbyid(r.id.etpassword); etusername = (edittext)findviewbyid(r.id.etusername); etserver = (edittext)findviewbyid(r.id.etserver); etport = (edittext)findviewbyid(r.id.etport); etemail.settext(uristring1); etusername.settext(uristring1); etpass.settext(uristring2); if((string.valueof(ddprotocol.getselecteditem())=="pop3"))//&&) { etport.settext("110"); if(string.valueof(ddsecurity.getselecteditem())=="non-ssl") { etport.settext("112"); } } btnext.setonclicklistener(this); btback.setonclicklistener(this); } @override public void onclick(view v) { // todo auto-generated method stub switch(v.getid()) { case r.id.bnext: break; case r.id.bback: break; } } }
on bnext want interact server , check setting.
Comments
Post a Comment