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. JavaScript 判断对象是否为空

    /** **判断是否null *@param data */ function isNull(data) {     return (data == "" || data == u ...

  2. 【HDOJ】1753 大明A+B

    注意数据格式,可以是整数,并且注意输出最简化浮点数. #include <stdio.h> #include <string.h> #define MAXNUM 420 cha ...

  3. 非sqlite和nigix的开源c项目

    1.http://code.google.com/p/friso/ 一.friso中文分词器 Friso是使用c语言开发的一款高性能中文分词器,使用流行的mmseg算法实现.完全基于模块化设计和实现, ...

  4. 作品第一课----获取批量checkbox选中的值

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. Linux Mono Asp.net 部署方案

    1.Jexus 国内的 官网:http://www.jexus.org 2.Apache 官网:http://mono-project.com/Mod_mono 3.Nginx 官网:http://m ...

  6. bzoj 1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居(set+并查集)

    Description 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发现她们已经结成了几个“群”.每只奶牛在吃草的 时候有一个独一无二的位置坐标Xi,Yi( ...

  7. Bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 深搜,bitset

    1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 554  Solved: 346[ ...

  8. Bzoj 2749: [HAOI2012]外星人 欧拉函数,数论,线性筛

    2749: [HAOI2012]外星人 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 568  Solved: 302[Submit][Status][ ...

  9. Get the largest sum of contiguous subarray in an int array

    When I finished reading this problem,I thought I could solve it by scanning every single subarray in ...

  10. debmirror镜像站

    如何建立一个Debian镜像网站呢?在Debian的官方网站已经有专门的介绍: http://www.debian.org/mirror/ftpmirror 这是基于rsync软件的方法,网页也提供了 ...