首页 > 其他 > 详细

Activity初接触

时间:2016-12-01 16:21:59      阅读:234      评论:0      收藏:0      [点我收藏+]

Activity中TextView的文字显示Hello Android:

1、直接显示:<TextView android:text="Hello Android" />

2、间接显示:<TextView android:text="@string/hello_android" />    (推荐)

  string.xml文件中<resources><string name="hello_android">Hello Android</string></resources>

 

启动另一个Activity:

1、创建主界面:my_layout.xml文件中<Button android:text="启动另一个Activity" android:id="@+id/btnStartAnotherAty" />

2、创建另一个Activity界面:java文件夹中创建一个AnotherAty,自动在layout文件夹中生成activity_another_aty.xml

3、功能实现:

  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //初始化时显示该页面
    setContentView(R.layout.my_layout);
    findViewById(R.id.btnStartAnotherAty).setOnClickListener(new View.OnClickListener(){
      @Override
      public void onClick(View v) {
        startActivity(new Intent(MainActivity.this,AnotherAty.class));
        // startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com")));  //跳转到百度页面
      }
    });
  }

 

 

Activity初接触

原文:http://www.cnblogs.com/MRDS-world/p/6122359.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!