android - Retrieving String From Java Class -
i new java / android programming , have been following tutorials / reading. have 2 classes called mainactivity , homeactivity, mainactivity user logs in , homepageactivity opened via intent if login correct.
the username passed through edit text have used following code in main class
string currentuser = edittextusername.gettext().tostring(); public string getcurrentuser () { return currentuser; }
and in homepage class
mainactivity testing = new mainactivity(); string x = testing.getcurrentuser(); currentusername.settext(x);
this seems should work me, how ever when launching application crashes, , without lines of code in main activity works fine
any ideas im doing wrong here guys
the string may null during setting textview check before setting textview
string currentuser = edittextusername.gettext().tostring(); public string getcurrentuser () { if(currentuser.length>0&¤tuser!="") return currentuser; else return "empty"; } string x = testing.getcurrentuser(); currentusername.settext(""+x);
Comments
Post a Comment