本例实现Android中简单Activity窗口切换:借助intent(意图)对应用操作(这里用按钮监听)等的描述,Android根据描述负责找对应的组件,完成组件的调用来实现活动的切换……案例比较简单直接附上代码了哈。

1、建两个Activity类,分别为MainActivity.java和GuideActivity.java……

MainActivity.java(核心文件):

package livetelecast.thonlon.example.cn.thonlonlivetelecast;
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 btn_oprnActivity;
@Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  btn_oprnActivity=(Button) findViewById(R.id.btn_openActivity);
  btn_oprnActivity.setOnClickListener(new View.OnClickListener() {
@Override
    public void onClick(View view) {
    Intent intent=new Intent();
    intent.setClass(MainActivity.this,GuidActivity.class);
    startActivity(intent);
     }
  });
  }
}

GuideActivity.java:

package livetelecast.thonlon.example.cn.thonlonlivetelecast;
import android.app.Activity;
import android.os.Bundle;
/**
* Created by NIUXINLONG on 2018/4/29.
*/
public class GuidActivity extends Activity{
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_guide);
  }
}

2、分别建立与Activity对应的布局文件activity_main.xml、activity_guide.xml:

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
  <Button
  android:id="@+id/btn_openActivity"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="@string/btn_open"/>
</RelativeLayout>

activity_guide.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
  <android.support.v4.view.ViewPager
  android:layout_width="match_parent"
  android:layout_height="match_parent">
  </android.support.v4.view.ViewPager>
  <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="bottom|center_horizontal">
    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/point_select"
    android:padding="15dp"/>
    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/point_normal"
    android:padding="15dp"/>
  </LinearLayout>
</FrameLayout>

3、配AndroidMenifest.xml:(重点是添加两activity)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="livetelecast.thonlon.example.cn.thonlonlivetelecast">
<application
  android:allowBackup="false"
  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=".MainActivity">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name=".GuidActivity"/>
</application>
</manifest>

 

Android中简单活动窗口的切换--Android的更多相关文章

  1. Android中使用ImageViewSwitcher实现图片切换轮播导航效果

    前面写过了使用ViewFlipper和ViewPager实现屏幕中视图切换的效果(ViewPager未实现轮播)附链接: Android中使用ViewFlipper实现屏幕切换 Android中使用V ...

  2. 解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题

    解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题http ...

  3. Android 中Activity生命周期分析:Android中横竖屏切换时的生命周期过程

    最近在面试Android,今天出了一个这样的题目,即如题: 我当时以为生命周期是这样的: onCreate --> onStart -- ---> onResume ---> onP ...

  4. Mono For Android中简单实现按钮的动画效果

    Android中动画的分Tween Animation和Frame Animation,本节主要讲Tween Animation的实现. 一般是通过XML文件来定义动画的,具体如下: 1.在项目res ...

  5. Android 中利用ViewFlipper 滑动屏幕切换页面,ListView展示数据

    首先新建一个Android项目,命名为ViewFlipperTest 如图:项目机构,本项目主要操作图中红色箭头标注的文件 1.HgroupAdapter.java文件代码↓主要实现listview数 ...

  6. Android学习记录(6)—将java中的多线程下载移植到Android中(即多线程下载在Android中的使用)③

    在这一节中,我们就来讲多线程下载以及断点续传在android中怎么使用,前两节是为本节做准备的,没有看前两节的同学,最好看完前面的两篇文章再来看这篇.其实在android端的应用和java基本上是差不 ...

  7. 在Android中自动实现横竖屏切换的问题

    http://developer.android.com/training/basics/supporting-devices/screens.html参照Google推荐的做法 在你项目的res 文 ...

  8. Android中密码输入内容可见性切换

    今天在做项目的时候遇到了一个关于密码输入框可见性切换问题,上网搜了搜,这里面门道还不小,做一个记录吧,下次遇到就好解决了. 首先写了一个简单的测试工程: <LinearLayout xmlns: ...

  9. Android中TweenAnimation四种动画切换效果

    点击每个按钮都会有对应的动画显示 activity代码: package com.tmacsky; import android.app.Activity; import android.os.Bun ...

随机推荐

  1. VC++ 判断一个文件是不是快捷方式

    转载:https://bbs.csdn.net/topics/34999 #include <iostream> #include <Shlobj.h> #include &l ...

  2. XcodeProj,使用Ruby更改工程文件

    利用xcodeproj修改xcode工程文件 一,Ruby基础 Ruby迭代器each.map.collect.inject each——连续访问集合的所有元素collect—-从集合中获得各个元素传 ...

  3. uniGUI试用笔记(十)

    今天用LoadRunner对uniGUI的Standalone模式的程序进行了一次压力测试,程序采用三层模式,将应用服务器与Web服务器分离,由于条件限制,数据库.应用服务和Web服务都部署在同一条云 ...

  4. UVA 818 Cutting Chains(状压 + 暴搜)题解

    题意:有1~n个小环,他们中的有些互相扣在一起,问你至少切开几个能把这写小环串成一条链 思路:还是太菜了,题目给的n<=15,显然可以暴力解决. 用二进制表示每个环切还是不切,然后搜索所有情况. ...

  5. cat查看文件以及sed查看指定行数

    https://unix.stackexchange.com/questions/288521/with-the-linux-cat-command-how-do-i-show-only-certai ...

  6. Excel lastindex of a substring

    I think I get what you mean. Let's say for example you want the right-most \ in the following string ...

  7. 改变onclick的作用域

  8. ffmpeg 下载安装和简单应用

    一.ffmpeg下载 先到http://ffmpeg.org/下载ffmpeg安装文件 二.ffmpeg安装 1.解压下载完的ffmpeg-20190319-f8075b2-win64-shared. ...

  9. yyyy-MM-dd'T'HH:mm:ss.SSS'Z'即UTC时间,与String日期转换

    本文为博主原创,未经允许不得转载: 最近在使用一个时间插件的时候,接收到的时间格式是 ’2017-11-27T03:16:03.944Z’ ,当我进行双向数据绑定的时候,由后台传过来的时间绑定到时间 ...

  10. [小问题笔记(九)] SQL语句Not IN 效率低,用 NOT EXISTS试试

    项目中遇到这么个情况: t1表 和 t2表  都是150w条数据,600M的样子,都不算大. 但是这样一句查询 ↓ select * from t1 where phone not in (selec ...