【风马一族_Android】通过菜单的点击,跳转到不同界面
---恢复内容开始---
布局的代码:activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sowsceo.sms.MainActivity"> <TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget> <FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
逻辑代码 :MainActivity.java
import android.app.TabActivity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost; public class MainActivity extends TabActivity { private TabHost mTabHos; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); initTabHost();
} /**
* 初始化tabHost
*/
private void initTabHost() {
mTabHos = (TabHost) findViewById(android.R.id.tabhost); addTabSpec("conversation","会话",R.drawable.tab_conversation,new Intent(this,ConversationUI.class));
addTabSpec("folder","文件夹",R.drawable.tab_folder,new Intent(this,FolderUI.class));
addTabSpec("group","群组",R.drawable.tab_group,new Intent(this,GroupUI.class)); } /**
* 添加一个页签
* @param tag 标记
* @param label 标题
* @param icon 图标
* @param intent 指向的activity
*/
private void addTabSpec(String tag,String label,int icon,Intent intent){
TabHost.TabSpec newTabSpec = mTabHos.newTabSpec(tag); newTabSpec.setIndicator(label,getResources().getDrawable(icon));
//设置页签的标题与图标 newTabSpec.setContent(intent);
//设置页签指向的显示内容问activity mTabHos.addTab(newTabSpec);
//添加页签
} }
------------------------------
三个菜单的布局与代码
------------------------------
会话布局:activity_conversation_ui.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sowsceo.sms.ConversationUI"> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="会话"
android:textSize="50sp"/>
</RelativeLayout>
逻辑代码:ConversationUI.java
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; /**
* 会话
*/
public class ConversationUI extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conversation_ui);
}
}
-------------------------------------------
布局代码:activity_folder_ui.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sowsceo.sms.FolderUI"> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="文件夹"
android:textSize="50sp" />
</RelativeLayout>
逻辑代码:FolderUI.java
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; /**
*
* 创建者:风马一族
* 时间: 2016/8/9 19:06
* 说明:文件夹
*/ public class FolderUI extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_folder_ui);
}
}
----------------------------------
布局代码:activity_group_ui.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sowsceo.sms.FolderUI"> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="文件夹"
android:textSize="50sp" />
</RelativeLayout>
---恢复内容结束---
【风马一族_Android】通过菜单的点击,跳转到不同界面的更多相关文章
- 【风马一族_Android】无线连接|调试Android手机
原文来自:http://www.cnblogs.com/sows/p/6269396.html (博客园的)风马一族 侵犯版本,后果自负 2017-01-10 15:03:31 准备阶段 1. 软 ...
- 【风马一族_Android】造作app的效果图
一.墨刀 官网:https://modao.cc
- 【风马一族_Android】手机与电脑通过adb进行连接
1:打开电脑的命令行 cmd 2:adb devices 查看与电脑连接的手机或模拟器的名称 3:准备要安装的apk.记住手机的名称 4:adb –s <模拟器名称> install & ...
- 【风马一族_Android】让app上传到Android市场的网站介绍
豌豆荚 开发者中心 http://open.wandoujia.com/account/info China app http://www.chinaapp.org
- 【风马一族_Android】Android Studio 给APP设置签名
在Android Studio中,给App签名,如果没有给App设置签名的话,Android Studio会主动给app设置一个默认的签名 接下来,介绍主动给App设置一个签名的整个步骤过程: 1) ...
- 【风马一族_Android】适合你 --- 大概的描述
适合你:专注于解决毕业生,离校所遗留的闲置教材的去向问题的一款APP. 目前的现状:毕业生的闲置教材,被清理宿舍的阿姨.大叔所清理到垃圾场,或拿到收破烂的地方,卖掉. 在毕业季中,存在的闲置物品不只有 ...
- 【风马一族_Android】强制activity的横屏与纵屏
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="ht ...
- 【风马一族_Android】多选按钮的监控事件
import android.app.Activity; import android.os.Bundle; import android.text.TextUtils; import android ...
- 【风马一族_Android】 图能
---------------------------------- 第一次 名称:相片查看器 ---------------------------------- 通过3D.自动播放幻灯片.旋转.跳 ...
随机推荐
- centos6.4搭建基于ftp的yum源让本地局域网服务器使用
1. 挂载centos6.4 DVD镜像[root@centos64 ~]# mount /dev/cdrom /mnt 2. 安装vsftp软件,启动vsftpd服务,拷贝centos6.4 DVD ...
- ArcGIS Server建立缓存(切图)原理解析[图解] (转载)
GoogleMap ,VirtualEarth ,YahooMap 等,目前所有的WebGIS都使用了缓存机制 以提高地图访问速度.原理都是将地图设定为多个比例尺,对于每个比例尺提前将地图分成若干小图 ...
- java中的xml与实体类之间的映射
实体类: package xml; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class User ...
- codeforce--Vasya and Petya's Game
网址:http://codeforces.com/contest/576/problem/A A. Vasya and Petya's Game time limit per test 1 secon ...
- VML/SVG在Web开发中一些常见的框架
1.借鉴自: http://www.codefans.net/soft/3061.shtml 来源于网上. flowchart.js http://adrai.github.io/flowchart ...
- 产生library cache latch原因
产生library cache latch原因The library cache latches protect the cached SQL statements and objects' defi ...
- Log4日志配置及使用
1.log4j.xml <?xml version="1.0" encoding="gb2312" ?> <!DOCTYPE log4j:co ...
- 三种硬件平台运行Laxcus大数据系统的表现
从2.0版本开始,Laxcus大数据管理系统开始支持POWERPC.X86.ARM三种平台.其中X86和ARM又分为32位和64位两种,POWERPC是纯64位,所以实际上共有五种平台,操作系统统一使 ...
- 【练习】显示MYSQL客户机选项
[oracle@enmo ~]$ mysql --help mysql Ver , for Linux (x86_64) using EditLine wrapper Copyright (c) , ...
- mysql显示乱码问题
在select * from table:时往往会出现上图所示乱码现象 此时,输入status,会发现: 此时只要SET NAMES utf8即可解决该问题.此时,再次输入status: 总结:S ...