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 calling
which is activity_main_user.xml which contains a series of textboxes and a "Save" button.I have written a method 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?
I am sorry that was a big typo !!Yes , i have defined the method in AddUserActivity.java , i have a button in activity_add_user.xml which should call save() method of AddActivityUser.java , based on some online help i found out that i have to create an Intent in MainActivity and then call the startActivity() method. Let me know if the approach is correct.
Joined: Mar 22, 2005
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.