Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6549667
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类: 嵌入式

2012-04-16 22:52:06

前一段时间,做移动的手机移动项目程序,在原来的程序中,阅读书籍或者显示书籍的章节列表的时候,在有多页的时候,翻页都是使用按钮(上一页,下一页,跳转)来实现页面的跳转,使用的时候不是很方便,上下页跳转的时候还可以,点一下按钮;页面要多页跳转的时候,就比较麻烦,大家都知道,有的ANDROID手机是没有键盘的,输入都是采用触摸屏。

后来客户需求变更,要求使用AndroidseekBar,实现使用滑动来快速实现页面的跳转,并在其他很多地方通过滑竿来设置,方便处理。

下面将我在最初做调研的程序分享给大家。程序运行的结果如下图:

首先,是要做好页面的布局工具,大家在做Android页面布局的时候,多使用layout来进行页面布局(虽然可以直接在java代码里进行页面布局的编写,但难度是相当的大)。本seekBar的页面布局如下:

xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=""

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:background="@android:color/white"

    >

<TextView android:id="@+id/myTv"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="@string/hello"

    />

<SeekBar android:id="@+id/seekbar" 

    android:layout_width="fill_parent" 

    android:layout_height="wrap_content" 

    

    

    android:progressDrawable="@layout/seekbar_style"   

    android:thumb="@layout/thumb" 

    android:layout_weight="1" 

    android:progress="0"

    android:secondaryProgress="0"

    android:thumbOffset="0dip"

    /> 

    <TextView

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="@string/hello"

    />

<SeekBar

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

     android:paddingLeft="10dip" 

    android:paddingRight="10dip" 

    />

LinearLayout>

       在页面上使用了一个文本,显示seekBar的进度,在seekBar滑动的时候实时的显示滑动的进度。为了实时显示,需要在seekBarsetOnSeekBarChangeListener方法中增加事件处理。如果不在这个方法中处理的话,那么只有在seekBar滑动停止的时候才可能显示出滑动的刻度而不能实时的显示。具体的seekBar的方法可以参考API手册。

这个只是seekBarDemo,在手机阅读程序中还需要融入具体的业务处理流程,如具体的页面值,滑动的刻度处理,在滑动过程中最终刻度的所在位置,比如当页码只有2页时,如果滑竿滑动超过50%会自动跳转到最末尾,少于50%需要跳转到最前面,等等这些都需要在相应的事件中增加处理,而还要对读书的Activity的操作,需要接口的回调等等。

具体的业务流程涉及部分知识产权,这里不便透露,只将我制作的Demo共享给大家。

 testSeekBar.rar   
阅读(5498) | 评论(4) | 转发(0) |
给主人留下些什么吧!~~

☆彼岸★花开2012-04-17 15:29:05

很好的博客,博主辛苦了~~