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. perl 面向对象demo

    Vsftp:/root/perl/17# cat Critter.pm package Critter; sub new { my $self = {}; my $invocant = shift; ...

  2. BZOJ_1588_&_Codevs_1296_[HNOI2002]_营业额统计(平衡树/set)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1588 给出每一天的营业值,求出之前的天当中与它相差最小的营业值与它的差的绝对值(第一天的差值为 ...

  3. WordPress Bradesco Gateway插件‘falha.php’跨站脚本漏洞

    漏洞名称: WordPress Bradesco Gateway插件‘falha.php’跨站脚本漏洞 CNNVD编号: CNNVD-201309-451 发布时间: 2013-09-26 更新时间: ...

  4. 通过 Azure 媒体服务进行高速编码

    Milan Gada Azure 媒体服务首席项目经理  关于 Azure 媒体服务,客户问的最多的一个问题是能否进行高速编码.这个问题现在已经有了肯定的答案,目前有三种不同类型的 Encodin ...

  5. 如何将数据库中已有表导入到powerDesigner生成pdm文件

    1.create new PDM: 2.select database menu; 3.click Reverse  Engineer database :4.then choose your scr ...

  6. JavaScript高级程序设计52.pdf

    表单脚本 表单的基础知识 在HTML中,表单是由<form>元素表示的,在Javascript对应的是HTMLFormElement类型,它继承自HTMLElement,因此具有与其他HT ...

  7. JavaScript高级程序设计41.pdf

    事件对象 在触发DOM上某个事件时,会产生一个事件对象event,这个对象中包含着所有与事件有关的信息. DOM中的事件对象 兼容DOM的浏览器会将event对象传入到事件处理程序中,无论指定事件处理 ...

  8. RHEL7 -- Linux搭建FTP虚拟用户

    安装vsftpd软件包[root@localhost ~]# yum install vsftpd -y [root@localhost ~]# yum install db4 db4-utils 建 ...

  9. python Day 2 - 编写数据库模块

    在一个Web App中,所有数据,包括用户信息.发布的日志.评论等,都存储在数据库中.在awesome-python-app中,我们选择MySQL作为数据库. Web App里面有很多地方都要访问数据 ...

  10. Code Forces Gym 100886J Sockets(二分)

    J - Sockets Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Valera ...