android - Calling Multiple Layouts in One Activity on 2 different Call Backs -



android - Calling Multiple Layouts in One Activity on 2 different Call Backs -

what doing initializing layout on start of activity. whenever button on layout clicked initializing layout in same activity. whenever click doing working regarding insertion of database record. on ignoring database part getting java null pointer exception in logcat. kindly have , guide me

package com.example.emp_management; import android.app.activity; import android.content.contentvalues; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.provider.syncstatecontract.columns; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.toast; import com.example.emp_management.databasehelper; public class administrator_work extends activity{ @override protected void oncreate(bundle adminkakaam) { // todo auto-generated method stub super.oncreate(adminkakaam); setcontentview(r.layout.administrator); toast.maketext(this, "logged in administrator!",toast.length_long).show(); final edittext new_user = (edittext) findviewbyid(r.id.edittext1); final edittext new_pass = (edittext) findviewbyid(r.id.textview2); button add_emp = (button)findviewbyid(r.id.addemployee); final button create_acc = (button) findviewbyid(r.id.creat_acc); add_emp.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub setcontentview(r.layout.add_employee); create_acc.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub //databasehelper accessing_db = new databasehelper(administrator_work.this); //accessing_db.insert_new_user(new_user.gettext().tostring(), new_pass.gettext().tostring()); //toast.maketext(getapplicationcontext(), "new user has been created!!", toast.length_short).show(); } }); } }); } }

calling setcontentview multiple times not recommended. advise utilize different fragments application, or @ to the lowest degree have first layout contain views need , hide/show them according needs. if insist on using different layouts same activity have here.

android android-layout android-button

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -