捕获登录名并在下一个活动中使用它

时间:2011-08-12 05:37:02

标签: android

我有一个登录页面;当我成功登录时,记录的人的名字应该出现在下一个活动中:

  

欢迎xyz

我该怎么做?

1 个答案:

答案 0 :(得分:2)

做这样的事情并且永远记住Phil的评论

登录活动

    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);
    }
欢迎活动

TextView view1 = (TextView)findViewById(R.id.textView1);
Bundle bundle = getIntent().getExtras();
String user=bundle.getString("userName"));
view1.setText("Welcome "+user);