Method not getting called inside an activity
Method not getting called inside an activity
I have just started to learn android by building very small and simple applications.I have created a simple app with 2 textboxes(edittext) and two buttons"Login" and "Add User".Currently I am not doing anything on click of "Login" button.But on click of "Add user" button, i am loading another screen from MainActivity.java by callingview plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
setContentView(R.layout.activity_add_user);
setContentView(R.layout.activity_add_user);
which is activity_main_user.xml which contains a series of textboxes and a "Save" button.I have written a methodview plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
saveUser()
saveUser() in AddUserActivity.java which currently just displays a message.But the problem is that logcat is throwing an exception saying it could not find saveUser() method in MainActivity.java.I have written the method in AddUserActivity.java , so how do i call the saveUser() method written in activity_main_user.xml ? Should i create a new activity from within MainActivity? The issue might be very basic one since i have just started learning.Please let me know where am i going wrong?
Are you explicitly starting the AddUserActivity? Just setting the activity_add_user layout does not start a new activity. The layout should be set in the onCreate method of the AddUserActivity class.
Also, what does "how do i call the saveUser() method written in activity_main_user.xml" mean? Methods are defined in classes, not layout files.
That sounds basically correct. Seeing some relevant excerpts of the code might help us understand what is (or is not) going on. Please UseCodeTags for that.