activity 的跳转
在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 的跳转的更多相关文章
- Android课程---Activity的跳转与传值(转自网上)
Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据. Intent是Android一个很重要的类.Intent直译是“意图”,什么是意图呢?比如你想从这个 ...
- Android activity界面跳转动画
实现activity界面跳转动画 1.在startActivity方法之后加入: overridePendingTransition(R.anim.pull_in_right, R.anim.pull ...
- Activity的跳转与传值(转载)
Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据. Intent是Android一个很重要的类.Intent直译是“意图”,什么是意图呢?比如你想从这个 ...
- android入门:activity之间跳转,并且回传参数
介绍: 两个activity进行跳转,在跳转过程中,将message由MainActivity传递到secondActivity,并且当secondActivity退回至MainAct ...
- Activity的跳转与传值
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://android.blog.51cto.com/268543/323982 Acti ...
- Activity基本跳转
详细解释:http://blog.csdn.net/xiazdong/article/details/7664757 简单介绍activity的跳转,通过intent实现,详细的注释在代码中.涉及到a ...
- Activity A 跳转到Activity B 生命周期
又被生命周期折磨了一段时间,这次是被onPause 和 onStop 折磨了,一直认为Activity A 跳转到到 Activity B的生命周期是onPause(A),onStop(A),onCr ...
- Android Activity间跳转与传递数据
1 概述 Activity之间的跳转主要使用 startActivity(Intent intent); startActivityForResult(Intent intent,int reques ...
- 5.10学习总结——Activity的跳转和传值
使用sharedpreference是对信息的存储,也可以进行传值,今天通过查找资料,学习了Activity的跳转和传值方法. 跳转 1.显示跳转 4种方法 1 2 3 4 5 6 7 8 9 10 ...
- 关于从Activity A跳转到Activity B ,其中Activity A中有一个VideoView,Activity B中有一个MediaPlayer。
两个不同的视频的跳转, 前面我是在onStop()方法中销毁VideoView(因为MediaPlayer是全局共用的,而VideoView内包含MediaPlayer),但是每次进入Activity ...
随机推荐
- Caddy – 方便够用的 HTTPS server 新手教程
最近发现了一个 golang 开发的 HTTP server,叫做 Caddy,它配置起来十分简便,甚至可以 28 秒配置好一个支持 http2 的 server ,而且对各种 http 新特性都支持 ...
- C++ for循环与迭代器
1.基本的for循环 std::vector<int> arr; ... for(std::vector<int>::iterator it=arr.begin();it!=a ...
- VMware激活密钥
VMware 2017 v14.x 永久许可证激活密钥FF31K-AHZD1-H8ETZ-8WWEZ-WUUVACV7T2-6WY5Q-48EWP-ZXY7X-QGUWD 原文链接
- Let's Encrypt申请证书及使用
Let's Encrypt是一个免费的.自动的,开放的CA. 形形色色有证书扩展名和类型,我是通过这篇文章明白个大体的:http://www.cnblogs.com/guogangj/p/411860 ...
- 2019/3/19 wen 运算符
- django自定义错误响应
在做一个web时,总是会出现各种错误,如400.403.404.500等.一般开发都要做对应的处理,给一些友好提示,或返回一些公益广告等. 在Django中,默认提供了常见的错误处理方式,比如: ha ...
- nginx 动态跨域配置
方法一: server { ..... set $cors_origin ""; if ($http_origin ~* "a.xxxx.com") { set ...
- c++ linux下输出中文
同样,使用的是VS FOR LINUX进行测试. converting to execution character set: Invalid or incomplete multibyte or w ...
- ORA-00600: internal error code, arguments: [13030], [20]一例解决
两年没有接触oracle了,中午,一环境update from的时候出现ORA-00600: internal error code, arguments: [13030], [20]异常,经查,官网 ...
- windows下openssl编译
昨晚,在编译rabbitmq-c时,使用cmake生成vs项目文件时遇到下列错误: CMake Error at C:/Program Files/CMake/share/cmake-3.6/Modu ...