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. 3.android下Makefile编写规范

    随着移动互联网的发展,移动开发也越来越吃香了,目前最火的莫过于android,android是什么就不用说了,android自从开源以来,就受到很多人的追捧.当然,一部人追捧它是因为它是Google开 ...

  2. 【HDOJ】4553 约会安排

    线段树.线段树的细节很重要,小数据遍历可以发现问题. /* 4553 */ #include <iostream> #include <string> #include < ...

  3. 我泡在GitHub上的177天 by Ryan Seys

    我泡在GitHub上的177天   这是一个关于我如何连续177天(将近半年)泡在GitHub上不间断地贡献代码的故事.我会谈到我为什么要这么做,以及为什么你也应该效仿,或者至少做点类似的事情.这是一 ...

  4. [原]RobotFrameWork(十一)AutoItLibrary测试库在win7(64bit)下安装及简单使用

    最近安装AutoItLibrary,发现在win7 x64下无法安装成功,后来经过定位,发现是3rdPartyTools\AutoIt目录下面AutoItX3.dll的问题.因为AutoItX3.dl ...

  5. HDU 1078 FatMouse and Cheese (记忆化搜索+dp)

    详见代码 #include <iostream> #include <cstdio> #include <cstdlib> #include <memory. ...

  6. c语音中打印参数调用层级即call stack, call trace

    http://stackoverflow.com/questions/105659/how-can-one-grab-a-stack-trace-in-c There's backtrace(), a ...

  7. DevExpress 用户控件 分页(下)

    分页控件调用 (1)初始化时: this.pageCtrl1.pageSize = 4; (2)数据绑定时: 从数据库中获取实时的 Public void LoadData(){ //这是只写有关分页 ...

  8. jQuery 简单归纳总结

    jQuery语法是为HTML元素的选取编制的,能够对元素运行某些操作. 基础语法是:$(selector).action() +美元符号定义 jQuery +选择符(selector)"查询 ...

  9. 检测到有潜在危险的Request.Form值

    由于在.net中,Request时出现有HTML或Javascript等字符串时,系统会认为是危险性值.立马报出“从客户端 中检测到有潜在危险的Request.Form值”这样的错. 用encodeU ...

  10. WCF - 学习总目录

    WCF - 基础 WCF - 地址 WCF - 绑定 WCF - 绑定后续之自定义绑定 WCF - 契约 WCF - 序列化 WCF - 消息 WCF - 实例与会话 WCF - REST服务