android - How to call function without using onClick -


i beginner of learning android. here want call endfun(view v) method oncreate(bundle savedinstancestate) method out using onclick.any 1 here suggest me.

  package com.example.loginandroid;  import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset;  import java.sql.sqlexception; import java.sql.statement; import android.os.bundle; import android.app.activity; import android.app.alertdialog; import android.util.log; import android.view.view; import android.widget.edittext; import android.widget.toast; import android.os.looper;  public class mainactivity extends activity{     string username,password;     resultset rs =null;     boolean temcfag=false,temqfag=true;     public static string tag="lifecycle activity";     edittext user,pass;     alertdialog.builder dialog;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         dialog=new alertdialog.builder(this);         dialog.setneutralbutton("ok", null);           user=(edittext)findviewbyid(r.id.edittext1);         pass=(edittext)findviewbyid(r.id.edittext2);          //i want call here endfun(view v) out using onclick      }        public void endfun(view v) throws sqlexception{         if(rs!=null){               if (rs.next()) {                log.v("test#######","errorrrrrrrrrrr1");                        setcontentview(r.layout.activity_main1);                     log.v("test#######","errorrrrrrrrrrr1");                      }              else{                    log.v("test#######","errorrrrrrrrrrr2");                dialog.setmessage("your username , password not valid");                 dialog.show();                 /*  toast.maketext(getapplicationcontext(), "username :"+username+"\n"+"password :"+password+"\n", toast.length_long).show();                log.v("test#######","errorrrrrrrrrrr2");*/              }}             else{                 log.v("out of loop","errorrrrrrrrrrr3");             }     }   } 

you can use null parameter:

endfun(null); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -