android - Alert Dialog closes without pressing anything_android -
i want code below razrada.show(); executing after press save on alertdialog, shows , closes code
alertdialog.builder razradaplacanja = new alertdialog.builder(noviracun.this); razradaplacanja.settitle("način plaćanja"); layoutinflater inflater = getlayoutinflater(); view vieww = inflater.inflate(r.layout.razrada, null); razradaplacanja.setview(vieww); final edittext gotovinaedit = (edittext) vieww.findviewbyid(r.id.gotovinaedit); final edittext karticeedit = (edittext) vieww.findviewbyid(r.id.karticeedit); razradaplacanja.setpositivebutton("save", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { try { json.put("totalcash", gotovinaedit.gettext().tostring()); json.put("totalcreditcards", karticeedit.gettext().tostring()); } catch (jsonexception e) { e.printstacktrace(); } } }); alertdialog razrada = razradaplacanja.create(); razrada.getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_visible); razrada.show(); //this want execute after pressing save racuni racun = getinsertresponse(requestinsert(base64encodedcredentials, json, httpclient1)); try { ...
i cannot put racuni racun = getinsertresponse(requestinsert(base64encodedcredentials, json, httpclient1)); inside onclick block cause racun unreachable (and if declared outside, needs final , cannot asign value)
thank kind of help!
you can move code want execute separate method:
public void someaction(jsontype json); { racuni racun = getinsertresponse(requestinsert(base64encodedcredentials, json, httpclient1)); // rest of code uses racun, etc. }
and call dialog's onclick()
method:
youractivity.this.someaction(json);
note code after show()
of alertdialog
executed immediately. show()
not blocking flow.
Comments
Post a Comment