Android中每个页面就是一个Activity,要合理的让这些页面实现跳转,才是关键,这里讲一个最简单的

首先,有一个主页面main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg"
> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" /> <TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.31" > <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/musicbutton"
android:onClick="OpmusicActivity"
/> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textbutton"
android:onClick="OptextActivity"
/> <Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vediobutton"
android:onClick="OpvedioActivity"
/> </TableRow> </LinearLayout>

这个页面有三个按钮,每个按钮都有对应的注册事件,就是为了触发该按钮的事件,去实现跳转事件,跳转的单个页面,太简单就不罗列出代码了,自己设计

主方法:MainActivity.java里面写出按钮所对应的事件,当事件发生的时候就会调用相应的方法,每一个方法中都有一个激活组件的方法

package com.szy.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View; public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
} public void OpmusicActivity(View v){
//点击音乐
Intent intent = new Intent();
intent.setClassName(this, "com.szy.test.MusicActivity");
startActivity(intent);
}
public void OptextActivity(View v){
//点击文本
Intent intent = new Intent();
intent.setClassName(this, "com.szy.test.TextActivity");
startActivity(intent); }
public void OpvedioActivity(View v){
//点击视频
Intent intent = new Intent();
intent.setClassName(this, "com.szy.test.VedioActivity");
startActivity(intent);
}
}

MusicActivity.java组件,该组件显示了一个页面

package com.szy.test;

import android.app.Activity;
import android.os.Bundle; public class MusicActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.music);
}
}

最后在AndroidManifest.xml对Activity进行注册:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.szy.test"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity android:label="@string/music"
android:name=".MusicActivity"
> </activity> <activity android:label="@string/text"
android:name=".TextActivity"
></activity> <activity android:label="@string/vedio"
android:name=".VedioActivity"
>
</activity> </application> </manifest>

这样就够实现点击按钮实现页面的跳转------

Java-Android 之页面的跳转和结构的搭建的更多相关文章

  1. Android Studio [页面的跳转和传值]

    AActivity.java package com.xdw.a122.jump; import android.app.Activity; import android.content.Compon ...

  2. 如何绑定android点击事件--跳转到另一个页面并实现关闭功能?

    一.点击按钮跳转到另一个页面. eg:实现从一个页面点击跳转到另一个页面 1.首先在一个布局文件(.XML)中绘画了一个跳转按钮(id为btn1): <Button         androi ...

  3. Android Intent实现页面之间跳转

    什么是IntentIntent可以理解为信使(意图)由Intent来协助完成Android各个组件之间的通讯Intent实现页面逐渐的跳转1.startActivity(inetnt)2.startA ...

  4. android屏幕页面实现滚动,页面跳转

    在 在LinearLayout外面包一层ScrollView即可,如下代码 Apidemo 中关于如何使用ScrollView说明,请参考:<ScrollView xmlns:android=& ...

  5. Android实现页面跳转、ListView及其事件

    Android实现页面跳转.ListView及其事件 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 进入主页面后,使用ListView实现特 ...

  6. Android tab_Host页面跳转,传值,刷新等问题汇总

    之前做了一个项目是关于Tab_Host的,现在完成了恰逢闲余写份总结,主要涉及里面遇到问题以及解决方案的. (首先说明这份代码是在eoe 下载的,这里感谢分享的那位朋友,限于我的工程是公司的不能拿出来 ...

  7. android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V

    今天在看布局文件的时候出现 android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[ ...

  8. Android笔记-4-实现登陆页面并跳转和简单的注册页面

    实现登陆页面并跳转和简单的注册页面   首先我们来看看布局的xml代码 login.xml <span style="font-family:Arial;font-size:18px; ...

  9. React-Native 之 GD (十)Android启动页面 及 模态方式跳转

    1.Android启动页面 思路:新建一个组件作为 Android 的启动页,index.android.js 的初始化窗口改为 Android启动页,设置定时器,使其在1.5秒后自动跳转到 Main ...

随机推荐

  1. vs2010 dll生成,使用问题[good]

    VS2010 动态库开发——第一章 演练:创建和使用动态链接库 (C++) 转载自[http://www.cnblogs.com/sdlypyzq/archive/2012/01/17/2324215 ...

  2. MySQL show status详解

    http://www.sandzhang.com/blog/2010/04/07/mysql-show-status-explained-detail/ 要查看MySQL运行状态,要优化MySQL运行 ...

  3. 通过Microsoft Azure服务设计网络架构的经验分享

    作者 王枫  发布于 2014年4月8日 本文从产品设计和架构角度分享了Microsoft Azure网络服务方面的使用经验,希望你在阅读本文之后能够了解这些服务之间,从而更好地设计你的架构. Mic ...

  4. ARM学习笔记2——分支跳转指令

    一.Arm指令条件码和条件助记符 二.跳转指令B 1.作用 跳转指令B使程序跳转到指定的地址执行程序(跳转范围是PC-32MB到PC+32MB) 2.指令格式(注:B后面如果有条件,条件就是紧跟在B后 ...

  5. Unity3d Fast Indirect illumination Using Two Virtual Spherical Gaussian Lights-Square Enix论文

    博主实现(in Unity3d 5) used one spotlight 史克威尔效果展示(夜光引擎?) 博主近期渲染:最近用unity5弄的一些渲染 ---- by wolf96  http:// ...

  6. leetcode旋转数组查找 二分查找的变形

    http://blog.csdn.net/pickless/article/details/9191075 Suppose a sorted array is rotated at some pivo ...

  7. UVa10895 Placing Lampposts

    UVa10895 Placing Lampposts 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34290 [思路] ...

  8. Bzoj 1391: [Ceoi2008]order 网络流,最大权闭合图

    1391: [Ceoi2008]order Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1105  Solved: 331[Submit][Statu ...

  9. useradd、passwd、userdel

    useradd是新建用户 userdel -r 是删除用户 passwd是修改密码 groupadd是新建组 groupdel是删除组 useradd yonghu  为添加用户 echo " ...

  10. Spark RDD/Core 编程 API入门系列 之rdd案例(map、filter、flatMap、groupByKey、reduceByKey、join、cogroupy等)(四)

    声明: 大数据中,最重要的算子操作是:join  !!! 典型的transformation和action val nums = sc.parallelize(1 to 10) //根据集合创建RDD ...