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

修改layout文件夹下activity_display_message.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
> <TextView
android:id="@+id/ttv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="edit_message"
android:textColor="#5500FF"
android:textSize="32sp"
android:padding="10dp"
/> <TextView
android:id="@+id/ttv2"
android:layout_width="355dp"
android:layout_height="wrap_content"
android:maxLines=""
android:ellipsize="end"
android:padding="10dp"
android:text="what are you going to do"
android:textColor="#00FF55"
android:textSize="32sp"
/> <TextView
android:id="@+id/ttv3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="More Info"
android:textSize="32sp"
android:padding="10dp"
/> </LinearLayout>

修改activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <Button
android:id="@+id/btnTextView1"
android:layout_width="223dp"
android:layout_height="69dp"
android:text="TestTextView" /> </LinearLayout>
修改MainActivity.java
package com.example.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button; public class MainActivity extends AppCompatActivity { private Button mBtnTextView; // define a text view button
@Override
protected void onCreate(Bundle x) {
super.onCreate(x);
setContentView(R.layout.activity_main);
mBtnTextView = findViewById(R.id.btnTextView1); // get the button, it is in activity_main.xml
mBtnTextView.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, DisplayMessageActivity.class);
startActivity(intent);
}
});
};
}

修改DisplayMessageActivity.java

package com.example.myapplication;

import android.graphics.Paint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView; public class DisplayMessageActivity extends AppCompatActivity { private TextView mtv1;
@Override
protected void onCreate(Bundle x) {
super.onCreate(x);
setContentView(R.layout.activity_display_message);
mtv1 = findViewById(R.id.ttv1);
mtv1.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); // set strike through style
mtv1.getPaint().setAntiAlias(true); // get rid of the zigzag effect
}
}

修改AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication"> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"> <activity android:name=".DisplayMessageActivity"
android:parentActivityName=".MainActivity" >
<!-- The meta-data tag is required if you support API level and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity> <activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </application> </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. Django模板系统 运算

    记下来,省得每次google 过滤器,变量的显示形式的改变 一.形式:小写 {{ name | lower }} 二.串联:先转义文本到HTML,再转换每行到 <p> 标签 {{ my_t ...

  2. redis3.0 主从

    redis3.0 主从 两个实例:6000为主,6001为从. 主实例配置如下: # replication repl-diskless-sync no repl-ping-slave-period ...

  3. Linux学习笔记之CentOS7配置***SS

    0x00 概述 最近安装K8S,镜像在国内不可达,只能通过科学方法获取. 0x01 安装配置Shadowsocks客户端 1.1 安装Sha.dows.ocks客户端 安装epel扩展源 采用Pyth ...

  4. Golang字符串解析成数字

    package main import ( "strconv" "fmt" ) func main() { // 使用ParseFloat解析浮点数,64是说明 ...

  5. VMware无法读取USB文件

    今天碰到虚拟机内的Mac OS无法读取USB,经过一番查看,是Windows的服务里面的vmware usb arbitration service服务没有启动,再点击启动的时候,报错,提示本地文件找 ...

  6. visual studio 2015下使用gcc调试linux c++开发环境搭建完整详解

    一直以来,相信绝大部分的开发都是windows/mac下做开发,尤其是非嵌入式和qt系的,而开源服务器程序绝大部分都是跑在Linux下,几乎就没有跑在windows下的.一直以来开发人员都是在wind ...

  7. linux下配置nginx使用ftp目录作为静态资源文件的目标目录

    1.安装ftp服务,可以直接yum install vsftpd. 2.设置随机启动,chkconfig vsftpd on. 3.启动ftp服务,service vsftpd start. 4.配置 ...

  8. numpy 学习笔记

    numpy 学习笔记 导入 numpy 包 import numpy as np 声明 ndarray 的几种方法 方法一,从list中创建 l = [[1,2,3], [4,5,6], [7,8,9 ...

  9. SVN Attempted to lock an already-locked dir异常解决方法

    Attempted to lock an already-locked dir异常解决方法 eclipse或myeclipse用svn提交的时候报错: Attempted to lock an alr ...

  10. phpstorm 一个窗口打开多个项目

    参考:https://imshusheng.com/php/135.html 文件 -> 设置 -> 项目"XXX" -> Directories- > A ...