android SDK开发 -- TitleBar封装(一)
假设app的title 统一的都是这种左中右结构的 代码如下
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/app_title_style"
android:baselineAligned="false"
android:gravity="center_vertical"
android:orientation="horizontal">
<ViewSwitcher
android:id="@+id/app_title_left_switcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/app_title_left_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回"/>
<ImageView
android:id="@+id/app_title_left_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</ViewSwitcher>
<ViewSwitcher
android:id="@+id/app_title_middle_switcher"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_weight="1">
<TextView
android:id="@+id/app_title_middle_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="title"/>
<ImageView
android:id="@+id/app_title_middle_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</ViewSwitcher>
<ViewSwitcher
android:id="@+id/app_title_right_switcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/app_title_right_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步"/>
<ImageView
android:id="@+id/app_title_right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</ViewSwitcher>
</LinearLayout>
先来继续完善一下BaseActivity
protected void onCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
ActivityMgr.push(this);
findViewById();
}
// 初始化app中通用的控件
protected void findViewById(){
}
// 设置标题栏
protected void setTitle(){
}
然后看一下BaseActivity的具体实现类TitleDemoActivity
public class TitleDemoActivity extendsBaseActivity{
protectedvoid onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
protectedvoid findViewById(){
setContentView(R.layout.title_demo);
super.findViewById();
super.setTitle();// 设置标题栏
}
}
TitleBar封装
BaseActivity的设计初衷是所有的Activity的都继承该类。
首先定义一些通用的属性、以及方法
子类调用
public class TitleDemoActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void findViewById() {
setContentView(R.layout.title_demo);
super.findViewById();
setTitle("返回主页", "这是一个Title", "下一个界面");
}
}
android SDK开发 -- TitleBar封装(一)的更多相关文章
- Android SDK 开发——发布使用踩坑之路
前言 在 Android 开发过程中,有些功能是通用的,或者是多个业务方都需要使用的. 为了统一功能逻辑及避免重复开发,因此将该功能开发成一个 SDK 是相当有必要的. 背景 刚好最近自己遇到了类似需 ...
- Android SDK开发与使用的那些事儿
前言 最近由于工作需要,将应用里的部分功能独立了出来,封装成 SDK 提供给合作伙伴使用.由于经验不足,网上也没多少写这方面内容的文章,遇到了不少的坑,决定记录下来. SDK 其实,刚说到要写SDK也 ...
- Android SDK 开发指南
Android SDK 开发指南 视频详解 以下视频是对融云 Android SDK 开发使用的详细讲解,您可以在阅读文档时配合学习. 更多视频教程如下: CSDN 融云 Android SDK ...
- 配置Android SDK 开发环境(转)
1. 下载Eclipse 在前面我们配置好了JDK环境后,就可以开始配置Android的集成开发环境了,官方Google推荐的集成开发环境为Eclipse,所以我们就以Eclipse作为集成开发环境. ...
- 基于虹软人证核验 2.0 Android SDK开发集成入门
一.功能介绍虹软人证核验 2.0 SDK(以下简称SDK)包含人脸检测.人脸跟踪.人证核验等能力,主要实现人证的1:1比对.其中暴露对外的功能方法有:active 引擎激活init 引擎初始化inpu ...
- Android SDK开发常用工具的使用及其异常处理
由于以下操作都是命令操作,所以在执行以下操作之前确保环境变量 ANDROID_HOME 指向的是正确的Android SDK的路径: 一.启动Android SDK Manager: android ...
- Google Android SDK开发范例------------20141119
一.Edit和Checkbox完成对登陆密码的查看:添加Edit的setOnCheckedChageListener和对CheckBox的状态通过isCHecked判断 大体代码如下 CheckBox ...
- Google Android SDK开发范例大全笔记 二
网络设备管理相关相关 代码地址 1 WifiManager LocationManager分别控制 wifi及GPS WifiManager 判断网络状态 ,LocationManager判断定位状态 ...
- Google Android SDK开发范例大全笔记 一
方法讲解 1 获取手机分辨率方法 DisplayMetrics private void getDiaplayMetrics() { DisplayMetrics dm = new DisplayMe ...
随机推荐
- __block存储类型
__block存储类型 你可以指定引入一个变量为可更改的,即读-写的,通过应用__block 存储类型修饰符.局部变量的__block 的存储和 register.auto.static 等存储类型相 ...
- php开发入门教程
LAMP window:WAMP(windows,apache,mysql,php) LAMP是 Linux,Apache,MySQL和PHP的缩写,是我们提供 Web 服务的软件基础. 对于 Lin ...
- JSP技术的优缺点介绍
什么是JSP?JSP可用一种简单易懂的等式表示为:HTML+Java=JSP. JSP技术使用Java编程语言编写类XML的tags和scriptlets,来封装产生动态网页的处理逻辑. 网页还能通过 ...
- 简述安装android开发环境
1, 安装java sdk2, 安装andoroid sdk3, 在环境变量里配置java和andoroid sdk的路径4, 部署eclipse,并在eclipse上安装ADT 补充: 步骤3之后需 ...
- ExtJS 4 类系统
ExtJS 4的类系统(class system)进行了一次重大重构,ExtJS4的新架构就是基于这套新的类系统构建的,因此有必要先了解以下这个class system这篇文章分为四章 I: &quo ...
- BZOJ 1069 最大土地面积
Description 在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. Input 第1行一个正整数N,接下来N行,每行2个数x,y ...
- ubuntu進入dos界面命令 ubuntu進入圖形界面命令
切换界面: ctrl + alt + F1是切到终端模式 Alt+F7 切到图形界面
- codeforces C. Inna and Huge Candy Matrix
http://codeforces.com/problemset/problem/400/C 题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋 ...
- 大用处--PowerShell Management Library for Hyper-V.
http://pshyperv.codeplex.com/releases 用脚本来收集及集成HYPER-V管理. 越来越似KVM,LIBVIRT啦.
- 根据div 标签 查看数组@class=modulwrap 下面的/table/tbody/tr/td
<div class="modulwrap"> <div class="request_title"> <span class=& ...