java - Is it possible to keep a Dialog open after clicking the Neutral Button? -


this question has answer here:

i have dialog 3 edittexts use ftp address, username, , password. used .setneutralbutton create button "test connection". got working connect ftp , show toast result don't want test button close dialog. how can keep dialog open during connection test?

livepreviewchk.setonclicklistener(new onclicklistener() {     @override     public void onclick(view v) {         linearlayout lila1 = new linearlayout(newsite.this);         lila1.setorientation(1); // 1 vertical orientation          final edittext servername = new edittext(newsite.this);         servername.sethint("server name");          final edittext serveraddress = new edittext(newsite.this);         serveraddress.sethint("server address");          final edittext username = new edittext(newsite.this);         username.sethint("username:");          final edittext password = new edittext(newsite.this);         password.sethint("password");          alertdialog.builder alt_bld = new alertdialog.builder(                 newsite.this);         alt_bld.seticon(r.drawable.ftpicon);         alt_bld.settitle("enter login details host ftp")                 .setcancelable(true)                 .setpositivebutton("save",                         new dialoginterface.onclicklistener() {                             public void onclick(dialoginterface dialog,                                     int id) {                                 }                             }                         })                 .setneutralbutton("test connection",                         new dialoginterface.onclicklistener() {                             public void onclick(dialoginterface dialog,                                     int id) {                                 ftpconnector testconnection = new ftpconnector();                                 boolean status = testconnection                                         .ftpconnect(host, user, pass,                                                 port);                                 if (status == true) {                                     connectionsuccessfull = true;                                 } else {                                     connectionsuccessfull = false;                                 }                             }                         })                 .setnegativebutton("cancel",                         new dialoginterface.onclicklistener() {                             public void onclick(dialoginterface dialog,                                     int id) {                                 // if button clicked, close                                 // dialog box , nothing                                 dialog.cancel();                             }                         });          lila1.addview(servername);         lila1.addview(serveraddress);         lila1.addview(username);         lila1.addview(password);          alertdialog alert = alt_bld.create();         alert.setview(lila1);         alert.show();     } }); 

from know, not possible without extending dialog class. however, functionality have may easier , better put in own activity , use dialog theme. have put code new activity , in manifest use dialog theme

<activity         android:name="com.your.package.yourclassname"         android:label="yourlabel"         android:theme="@android:style/theme.dialog" > </activity> 

this give , feel of dialog while being contained in own activity

here so answer on extending dialog. haven't looked through looks may give need if choose option.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -