大家好,今天是元旦节了,祝大家节日快乐!今天给大家分享的是Apad Qzone的UI框架,我们首先看下交互图如下:

图1:交互效果图.
从上图可以看出,整个应用其实UI框架相对比较简单,可以分为俩部分,左侧导航栏区域,右侧显示内容区域。当我们点击左侧导航栏时,右侧显示相对应内容。
应用的主要内容分为四个模块:好友动态;个人主页;好友列表;应用中心。右侧显示内容则统一由一个管理器管理,管理器管理了右侧的容器以及显示内容面板。
也许用文字不太好说清楚,所以我写了一个简单的Demo以及画了一个UI结构图方便大家理解:
首先是新建一个Android工程,命名为QzoneFrameDemo,结构如下:

图2:程序代码结构图:
为了更容易理解代码,我画了一个各个类的关系图如下:

上图可以清晰的看清各个类之间的关系,其中QZRightWindowManger管理了QZRightWindowContainer(剪头忘记加了)和右侧的四个Window,QZRightWindowContainer继承了FrameLayout,四个Window继承了QZRightWindowBase。
其中QZRightWindowContainer代码如下(继承了FrameLayout):
package com.tutor.frame;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class QZRightWindowContainer extends FrameLayout {
public QZRightWindowContainer(Context context){
super(context);
}
public QZRightWindowContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
}
而右侧四个Window的基类QZRightWindowBase的代码如下:
package com.tutor.frame;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.TextView;
public abstract class QZRightWindowBase extends FrameLayout {
public TextView mContentTextView;
private LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
public QZRightWindowBase(Context context){
super(context);
setupViews();
}
public QZRightWindowBase(Context context, AttributeSet attrs) {
super(context, attrs);
setupViews();
}
private void setupViews(){
mContentTextView = new TextView(getContext());
mContentTextView.setLayoutParams(params);
}
//做些事为了扩展举例而已
public abstract void dosomething();
//做些事2
public abstract void dosomething2();
}
右侧窗口Window1即QZRightWindow1代码(其他的都一样不贴代码了)如下:
package com.tutor.frame;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
public class QZRightWindow1 extends QZRightWindowBase{
public QZRightWindow1(Context context){
super(context);
setupViews();
}
public QZRightWindow1(Context context, AttributeSet attrs) {
super(context, attrs);
setupViews();
}
private void setupViews(){
mContentTextView.setText("好友动态");
mContentTextView.setBackgroundColor(Color.RED);
addView(mContentTextView);
}
@Override
public void dosomething() {
// TODO Auto-generated method stub
}
@Override
public void dosomething2() {
// TODO Auto-generated method stub
}
}
管理QZRightWindowContainer和右侧四个Window的管理类QZRightWindowManager代码如下:
package com.tutor.frame;
import java.util.HashMap;
import java.util.Iterator;
import android.view.View;
public class QZRightWindowManager {
/**
* 好友动态面板的KEY
*/
public static final int FRIEND_TRENDS_WINDOW = 0;
/**
* 个人中心面板的KEY
*/
public static final int HOME_PAGE_WINDOW = 1;
/**
* 好友关系链面板的KEY
*/
public static final int FRIEND_LIST_WINDOW = 2;
/**
* 应用中心面板的KEY
*/
public static final int APP_CENTER_WINDOW = 3;
private HashMap<Integer, QZRightWindowBase> mHashMap;
private QZRightWindowContainer mContainer;
public QZRightWindowManager(){
mHashMap = new HashMap<Integer, QZRightWindowBase>();
}
public void setmContainer(QZRightWindowContainer container) {
this.mContainer = container;
}
public void showRightWindow(int num,QZRightWindowBase mQzRightWindowBase){
if(!mHashMap.containsKey(num)){
mHashMap.put(num, mQzRightWindowBase);
if(!(mQzRightWindowBase instanceof QZRightWindow1)){
mContainer.addView(mQzRightWindowBase);
}
}
for (Iterator iter = mHashMap.keySet().iterator(); iter.hasNext();) {
Object key = iter.next();
QZRightWindowBase qzb = mHashMap.get(key);
qzb.setVisibility(View.INVISIBLE);
}
mQzRightWindowBase.setVisibility(View.VISIBLE);
}
}
主程序QzoneFrameDemoActivity代码如下:
package com.tutor.framedemo;
import com.tutor.frame.QZLeftNavBar;
import com.tutor.frame.QZRightWindow1;
import com.tutor.frame.QZRightWindow2;
import com.tutor.frame.QZRightWindow3;
import com.tutor.frame.QZRightWindow4;
import com.tutor.frame.QZRightWindowBase;
import com.tutor.frame.QZRightWindowContainer;
import com.tutor.frame.QZRightWindowManager;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
public class QzoneFrameDemoActivity extends Activity implements OnClickListener{
private QZRightWindow1 mQzRightWindow1;
private QZRightWindow2 mQzRightWindow2;
private QZRightWindow3 mQzRightWindow3;
private QZRightWindow4 mQzRightWindow4;
private QZLeftNavBar mQzLeftNavBar;
private QZRightWindowContainer mQzRightWindowContainer;
private QZRightWindowManager mQzRightWindowManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setupViews();
}
private void setupViews(){
mQzRightWindowManager = new QZRightWindowManager();
mQzLeftNavBar = (QZLeftNavBar)findViewById(R.id.navbar);
mQzLeftNavBar.findViewById(R.id.rw1).setOnClickListener(this);
mQzLeftNavBar.findViewById(R.id.rw2).setOnClickListener(this);
mQzLeftNavBar.findViewById(R.id.rw3).setOnClickListener(this);
mQzLeftNavBar.findViewById(R.id.rw4).setOnClickListener(this);
mQzRightWindow1 = (QZRightWindow1)findViewById(R.id.qzrw1);
mQzRightWindowContainer = (QZRightWindowContainer)findViewById(R.id.container);
mQzRightWindowManager.setmContainer(mQzRightWindowContainer);
}
private void showRightWindow(int num,QZRightWindowBase mQzRightWindowBase){
mQzRightWindowManager.showRightWindow(num, mQzRightWindowBase);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.rw1:
showRightWindow(QZRightWindowManager.FRIEND_TRENDS_WINDOW, mQzRightWindow1);
break;
case R.id.rw2:
if(mQzRightWindow2 == null){
mQzRightWindow2 = new QZRightWindow2(this);
}
showRightWindow(QZRightWindowManager.HOME_PAGE_WINDOW, mQzRightWindow2);
break;
case R.id.rw3:
if(mQzRightWindow3 == null){
mQzRightWindow3 = new QZRightWindow3(this);
}
showRightWindow(QZRightWindowManager.FRIEND_LIST_WINDOW, mQzRightWindow3);
break;
case R.id.rw4:
if(mQzRightWindow4 == null){
mQzRightWindow4 = new QZRightWindow4(this);
}
showRightWindow(QZRightWindowManager.APP_CENTER_WINDOW, mQzRightWindow4);
break;
default:
break;
}
}
}
主程序所用到的布局文件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="horizontal" >
<com.tutor.frame.QZLeftNavBar
android:id="@+id/navbar"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
<com.tutor.frame.QZRightWindowContainer
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.tutor.frame.QZRightWindow1
android:id="@+id/qzrw1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</com.tutor.frame.QZRightWindowContainer>
</LinearLayout>
运行效果如下:

效果1

效果2.
OK,这样就大功告成了!对于pad上面的应用,单Activity化,各个功能模块化,UI控件化,是比较好的选择,这样可以加大开发效率,减少和其他同学的耦合性。
下面的链接是源代码,供新手们学习用,今天就讲到这里,谢谢大家!!!
源代码点击进入==>
分享到:
相关推荐
Apad Qzone UI框架可能是针对平板电脑(Apad)优化的,因为“Apad”通常指的是Android平板设备。这样的框架能够帮助开发者快速创建符合平板屏幕特性的界面,例如大屏幕适配、多点触控支持等。 在QzoneFrameDemo这个...
这个项目旨在简化用户对Qzone皮肤的操作,提升用户在平板设备(Apad)上使用QQ空间的视觉效果和交互体验。 在Android开发中,皮肤管理器通常涉及以下几个核心知识点: 1. **资源管理**:Android应用的皮肤本质上是...
QQ HD是腾讯公司针对平板电脑Android平台开发的一款增强版即时通讯应用,旨在提供高清流畅的视频聊天、音乐播放以及丰富的社交功能。近期,QQ HD推出了全新的Mini版本,以适应7寸以下屏幕的Android平板用户。 1. **...
由于Apad是开源项目,因此它背后有一个活跃的开发者和用户社区。这个社区不断贡献新的插件、主题和改进,确保软件始终与时俱进。用户可以通过论坛、邮件列表或者GitHub等平台寻求帮助、分享经验,或者参与到Apad的...
最新LinPay码支付 免签支付系统源码 免授权版本 服务集成商兼容市面所有易支付,兼容所有商城LinPay是专为个人站长打造的聚合免签系统,拥有卓越的性能和丰富的功能。...5.QQ最新框架协议永不掉线
-apad audio pad -frames number set the number of frames to output -filter filter_graph set stream filtergraph -filter_script filename read stream filtergraph description from a file -reinit_filter ...
LinPay码支付是2024年8月25日上线的一款新码支付,属于第四方支付不需要支付许可证云拍照,服务集成商兼容市面所有易支付,兼容所有商城LinPay是专为个人站长打造的聚合免签系统,拥有卓越...5.QQ最新框架协议永不掉线
VS Code QQ扩展 | 暂时实现了一些最基础的功能,可用于上班时缓解工作压力摸鱼 在扩展市场搜索qq或在发行中下载。安装后点击状态栏里的按钮登录。需要安装chrome浏览器完成滑动验证码(若无chrome请根据提示手动...
微生物技术在固体废物处理中的应用,特别是在城市污水处理和一些工业废水处理中,具有显著的意义。这一领域的核心关注点包括剩余污泥的发酵、脱水,生活垃圾的堆肥处理,以及生活垃圾的卫生填埋。本章主要探讨了剩余...
apad:一天的问题该应用程序每天通过 uHunt API 从 CP3 问题列表中随机生成 uVa 问题。笔记如果通过 HTTPS 页面连接,到 uHunt 的连接将被浏览器阻止(虽然可以关闭),因为 uHunt 仅在 HTTP 连接中提供服务。 请...
package allone.verbank.apad.client.component; import android.text.InputFilter; import android.text.Spanned; /** * * @Title: ComponentDigitCtrlFilter.java * @Package allone.verbank.apad.client....
一个网站等于多个网站 支持:PC电脑、Iphone手机 、Ipad平板电脑 ,Apad平板电脑,Android手机等多种移动设备正常访问。 产品特色: 1核心采用Thinkphp框架开发,MVC架构,灵活强大的功能扩展机制 2多种服务器...
属于第四方支付不需要支付许可证云拍照,服务集成商兼容市面所有易支付,兼容所有商城LinPay是专为个人站长打造的聚合免签系统,拥有卓越的性能和丰富的功能。 采用全新轻量化的界面UI ...5.QQ最新框架协议永不掉线
- **选择题第六题**:“APAD”等选项可能代表不同的编程模式或设计模式。 #### 4. 程序设计与开发 - **选择题第七题**:“Aϵͳĸ”至“Dʱ”可能涉及到程序设计的原则、方法或步骤。 - **选择题第八题**:“Aݿϵ...
描述iPad,aPad持续集成方案。包括构建打包,静态检测,自动安装,自动化测试,测试代码覆盖率统计分析。
56播放器安装包下载,56video_APad.apk
AsyPad 一个简单的绘图工具,可以将图表转换为渐近线... 按⌘S/ Ctrl + S保存为AsyPad(.apad)文件。 按⌘Shift+ S / Ctrl + Shift + S保存为渐近线(.asy)文件。 按⌘O/ Ctrl + O加载AsyPad(.apad)文件。 撤消/
这是一个RK2808的USB 驱动软件,用于在国内板IPAD刷机前的驱动,试过在WIN7内运行不到,在XP内就完全顺利。