开发者

Android: Retrieving data from previous activity

开发者 https://www.devze.com 2023-03-27 20:37 出处:网络
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 directe

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消