在app文件夹上右键新建空的activity ,名称为DisplayMessageActivity,

修改layout文件夹下activity_display_message.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical"
  6. >
  7.  
  8. <TextView
  9. android:id="@+id/ttv1"
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:text="edit_message"
  13. android:textColor="#5500FF"
  14. android:textSize="32sp"
  15. android:padding="10dp"
  16. />
  17.  
  18. <TextView
  19. android:id="@+id/ttv2"
  20. android:layout_width="355dp"
  21. android:layout_height="wrap_content"
  22. android:maxLines=""
  23. android:ellipsize="end"
  24. android:padding="10dp"
  25. android:text="what are you going to do"
  26. android:textColor="#00FF55"
  27. android:textSize="32sp"
  28. />
  29.  
  30. <TextView
  31. android:id="@+id/ttv3"
  32. android:layout_width="match_parent"
  33. android:layout_height="wrap_content"
  34. android:text="More Info"
  35. android:textSize="32sp"
  36. android:padding="10dp"
  37. />
  38.  
  39. </LinearLayout>

修改activity_main.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical">
  6.  
  7. <Button
  8. android:id="@+id/btnTextView1"
  9. android:layout_width="223dp"
  10. android:layout_height="69dp"
  11. android:text="TestTextView" />
  12.  
  13. </LinearLayout>
  1. 修改MainActivity.java
  1. package com.example.myapplication;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.Button;
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10.  
  11. private Button mBtnTextView; // define a text view button
  12. @Override
  13. protected void onCreate(Bundle x) {
  14. super.onCreate(x);
  15. setContentView(R.layout.activity_main);
  16. mBtnTextView = findViewById(R.id.btnTextView1); // get the button, it is in activity_main.xml
  17. mBtnTextView.setOnClickListener(new View.OnClickListener() {
  18. public void onClick(View view) {
  19. Intent intent = new Intent(MainActivity.this, DisplayMessageActivity.class);
  20. startActivity(intent);
  21. }
  22. });
  23. };
  24. }

修改DisplayMessageActivity.java

  1. package com.example.myapplication;
  2.  
  3. import android.graphics.Paint;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.widget.TextView;
  7.  
  8. public class DisplayMessageActivity extends AppCompatActivity {
  9.  
  10. private TextView mtv1;
  11. @Override
  12. protected void onCreate(Bundle x) {
  13. super.onCreate(x);
  14. setContentView(R.layout.activity_display_message);
  15. mtv1 = findViewById(R.id.ttv1);
  16. mtv1.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); // set strike through style
  17. mtv1.getPaint().setAntiAlias(true); // get rid of the zigzag effect
  18. }
  19. }

修改AndroidManifest.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.example.myapplication">
  4.  
  5. <application
  6. android:allowBackup="true"
  7. android:icon="@mipmap/ic_launcher"
  8. android:label="@string/app_name"
  9. android:roundIcon="@mipmap/ic_launcher_round"
  10. android:supportsRtl="true"
  11. android:theme="@style/AppTheme">
  12.  
  13. <activity android:name=".DisplayMessageActivity"
  14. android:parentActivityName=".MainActivity" >
  15. <!-- The meta-data tag is required if you support API level and lower -->
  16. <meta-data
  17. android:name="android.support.PARENT_ACTIVITY"
  18. android:value=".MainActivity" />
  19. </activity>
  20.  
  21. <activity android:name=".MainActivity">
  22. <intent-filter>
  23. <action android:name="android.intent.action.MAIN" />
  24.  
  25. <category android:name="android.intent.category.LAUNCHER" />
  26. </intent-filter>
  27. </activity>
  28.  
  29. </application>
  30.  
  31. </manifest>

点击运行!

activity 的跳转的更多相关文章

  1. Android课程---Activity的跳转与传值(转自网上)

    Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据.   Intent是Android一个很重要的类.Intent直译是“意图”,什么是意图呢?比如你想从这个 ...

  2. Android activity界面跳转动画

    实现activity界面跳转动画 1.在startActivity方法之后加入: overridePendingTransition(R.anim.pull_in_right, R.anim.pull ...

  3. Activity的跳转与传值(转载)

    Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据.   Intent是Android一个很重要的类.Intent直译是“意图”,什么是意图呢?比如你想从这个 ...

  4. android入门:activity之间跳转,并且回传参数

    介绍:         两个activity进行跳转,在跳转过程中,将message由MainActivity传递到secondActivity,并且当secondActivity退回至MainAct ...

  5. Activity的跳转与传值

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://android.blog.51cto.com/268543/323982 Acti ...

  6. Activity基本跳转

    详细解释:http://blog.csdn.net/xiazdong/article/details/7664757 简单介绍activity的跳转,通过intent实现,详细的注释在代码中.涉及到a ...

  7. Activity A 跳转到Activity B 生命周期

    又被生命周期折磨了一段时间,这次是被onPause 和 onStop 折磨了,一直认为Activity A 跳转到到 Activity B的生命周期是onPause(A),onStop(A),onCr ...

  8. Android Activity间跳转与传递数据

    1 概述 Activity之间的跳转主要使用 startActivity(Intent intent); startActivityForResult(Intent intent,int reques ...

  9. 5.10学习总结——Activity的跳转和传值

    使用sharedpreference是对信息的存储,也可以进行传值,今天通过查找资料,学习了Activity的跳转和传值方法. 跳转 1.显示跳转 4种方法 1 2 3 4 5 6 7 8 9 10 ...

  10. 关于从Activity A跳转到Activity B ,其中Activity A中有一个VideoView,Activity B中有一个MediaPlayer。

    两个不同的视频的跳转, 前面我是在onStop()方法中销毁VideoView(因为MediaPlayer是全局共用的,而VideoView内包含MediaPlayer),但是每次进入Activity ...

随机推荐

  1. Caddy – 方便够用的 HTTPS server 新手教程

    最近发现了一个 golang 开发的 HTTP server,叫做 Caddy,它配置起来十分简便,甚至可以 28 秒配置好一个支持 http2 的 server ,而且对各种 http 新特性都支持 ...

  2. C++ for循环与迭代器

    1.基本的for循环 std::vector<int> arr; ... for(std::vector<int>::iterator it=arr.begin();it!=a ...

  3. VMware激活密钥

    VMware 2017 v14.x 永久许可证激活密钥FF31K-AHZD1-H8ETZ-8WWEZ-WUUVACV7T2-6WY5Q-48EWP-ZXY7X-QGUWD 原文链接

  4. Let's Encrypt申请证书及使用

    Let's Encrypt是一个免费的.自动的,开放的CA. 形形色色有证书扩展名和类型,我是通过这篇文章明白个大体的:http://www.cnblogs.com/guogangj/p/411860 ...

  5. 2019/3/19 wen 运算符

  6. django自定义错误响应

    在做一个web时,总是会出现各种错误,如400.403.404.500等.一般开发都要做对应的处理,给一些友好提示,或返回一些公益广告等. 在Django中,默认提供了常见的错误处理方式,比如: ha ...

  7. nginx 动态跨域配置

    方法一: server { ..... set $cors_origin ""; if ($http_origin ~* "a.xxxx.com") { set ...

  8. c++ linux下输出中文

    同样,使用的是VS FOR LINUX进行测试. converting to execution character set: Invalid or incomplete multibyte or w ...

  9. ORA-00600: internal error code, arguments: [13030], [20]一例解决

    两年没有接触oracle了,中午,一环境update from的时候出现ORA-00600: internal error code, arguments: [13030], [20]异常,经查,官网 ...

  10. windows下openssl编译

    昨晚,在编译rabbitmq-c时,使用cmake生成vs项目文件时遇到下列错误: CMake Error at C:/Program Files/CMake/share/cmake-3.6/Modu ...