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

 

 

转载于:https://www.cnblogs.com/MRDS-world/p/6122359.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值