java - One button for 2 different actions -


i have "send" button inside dialogfragment onclick event push new data firebase under key value.

i want button "update" button when user click on particular button. data update in firebase under same key value before.

this send button onclick method:

send_btn.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                      //some code .....//                      databasereference newpost = mdatabase.push();                     str_key = newpost.getkey();                     trempdata = new trempdata(str_key, str_uid, str_name, str_phone, str_from, str_to, str_date, str_time, str_extra, str_timestamp);                     newpost.setvalue(trempdata);                    toast.maketext(getactivity(), "tremp added", toast.length_short).show();                     dismiss();                 }           }); 

any suggestions?

this example :

private final int button_update = 1; private final int button_send = 2; private int buttonstatus = 0;  send_btn.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {           switch(buttonstatus)           {             case button_update: { // update code here}             case button_send : { // send code here         } 

the buttonstatus control operation button do.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -