Activity初接触

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")));  //跳转到百度页面
      }
    });
  }

 

 

posted @ 2016-12-01 16:05  Sheldon_wz  阅读(182)  评论(0编辑  收藏  举报