at the moment I have my user and password fields in a login screen.
The user enters t开发者_运维问答hese credentials and then on successful login the login activity its closed and the user is directed to a menu page.
What I want to do is use the username entered in the login field to create a 'Hello USERNAME' sentence in the menu.
not really too sure of how to do this. Could someone help.
Do something like this
In Login Activity
String userName;
if(login_ok){
final Intent i = new Intent(Login.this, Welcome.class);
i.putExtras("userName",userName);//sending checked value to next activity
startActivity(i);
}
in welcome Activity
TextView view1 = (TextView)findViewById(R.id.textView1);
Bundle bundle = getIntent().getExtras();
String user=bundle.getString("userName"));
view1.setText("Welcome "+user);
精彩评论