【风马一族_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.自动播放幻灯片.旋转.跳 ...
随机推荐
- NoSQL分类及ehcache memcache redis 三大缓存的对比
NoSQL分类 由于NoSQL中没有像传统数据库那样定义数据的组织方式为关系型的,所以只要内部的数据组织采用了非关系型的方式,就可以称之为NoSQL数据库.目前,可以将众多的NoSQL数据库按照内部的 ...
- 保持UIImagePickerController后导航栏风格统一
1. UIImagePickerController 状态栏始终保持某一种风格. -(void)navigationController:(UINavigationController *)navig ...
- 想直接用Windows API开发程序,你真的应该知道这些!
1,Windows数据类型. 2,Windows数据类型命名规律. 3,匈牙利表示法.
- 查看linux的版本
1. uname -a ~$ uname -a Linux lubuntu-Vostro-A840 3.19.0-73-generic #81-Ubuntu SMP Tue Oct 18 16:02: ...
- C++学习40 抛出自己的异常
throw 是C++中的关键字,用来抛出异常.如果不使用 throw 关键字,try 就什么也捕获不到:上节提到的 at() 函数在内部也使用了 throw 关键字来抛出异常. throw 既可以用在 ...
- php array函数实例应用
array_diff_key() array_diff_assoc() array_count_values() array_combine() array_column() array_chunk( ...
- Android——显示单位px和dip以及sp的区别
dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和QVGA 推荐使用这个,不依赖像素.d ...
- 翻译:深入 AngularUI Router
原文地址:http://www.ng-newsletter.com/posts/angular-ui-router.html ui-router: https://angular-ui.github. ...
- Bootstrap 3 How-To #2 标题,链接与按钮
这个系列的要点来自一本名为 Twitter Bootstrap Web Development How-to 的书,但是,这本书的内容是基于以前版本的,与最新的 3.0 并不一致. 为了方便学习和使用 ...
- 剑指Offer:面试题15——链表中倒数第k个结点(java实现)
问题描述 输入一个链表,输出该链表中倒数第k个结点.(尾结点是倒数第一个) 结点定义如下: public class ListNode { int val; ListNode next = null; ...