Android中Activity的切换
| [日期:2011-07-31] |
来源:Linux社区
作者:wangchenggong1988 |
[字体:大 中 小]
|
登陆成功后跳转的页面对应的Activity
- <span style="color:#666666;">public class SucActivity extends Activity implements OnClickListener{
-
- private TextView textView;
-
- private Button button ;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.suc);
-
- textView = (TextView) findViewById(R.id.result);
- button = (Button) findViewById(R.id.examplebutton);
-
- button.setOnClickListener(this);
-
- </span><span style="font-size:32px;color:#999900;"><strong><em>咋放咋取</em></strong></span><span style="color:#666666;">
- Intent intent = getIntent(); </span><span style="color: rgb(51, 204, 0); ">如果采用的是intent直接装常规的数据类型</span><span style="color:#666666;">
-
- User user = (User) intent.getSerializableExtra("user");</span><span style="color:#666666;"><span style="color: rgb(51, 204, 0); ">用intent装载实现可序列化接口的类</span>
- </span>
- <span style="color:#666666;">String name = user.getName();
- String pwd = user.getPwd();
-
- textView.setText("欢迎你," + name);</span>
- <span style="font-size:24px;color:#ff9900;background-color: rgb(51, 102, 255);"><strong>其实到这里,任务已经完成,但需要知道,Activity的切换不仅可以发生在同一个应用程序中,还可以发生在不同的应用程序之间</strong></span>
- <span style="color:#666666;">
-
- <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public void onClick(View v) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">Uri uri = Uri.parse("smsto:111000");
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">Intent intent = new Intent(Intent.ACTION_SENDTO,uri);
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">intent.putExtra("sms_body", "Hello,Android!This is a sms!");
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">startActivity(intent);
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">}
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">
</span><span style="color: rgb(102, 102, 102); white-space: pre; "> </span><span style="color:#666666;">
</span>
-
- <span style="color:#666666;">
- }
- </span>

评论声明
- 尊重网上道德,遵守中华人民共和国的各项有关法律法规
- 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
- 本站管理人员有权保留或删除其管辖留言中的任意内容
- 本站有权在网站内转载或引用您的评论
- 参与本评论即表明您已经阅读并接受上述条款
|
|
|
|