Android移动终端开发大作业Word文档格式.docx

上传人:b****5 文档编号:21477083 上传时间:2023-01-30 格式:DOCX 页数:25 大小:52.28KB
下载 相关 举报
Android移动终端开发大作业Word文档格式.docx_第1页
第1页 / 共25页
Android移动终端开发大作业Word文档格式.docx_第2页
第2页 / 共25页
Android移动终端开发大作业Word文档格式.docx_第3页
第3页 / 共25页
Android移动终端开发大作业Word文档格式.docx_第4页
第4页 / 共25页
Android移动终端开发大作业Word文档格式.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

Android移动终端开发大作业Word文档格式.docx

《Android移动终端开发大作业Word文档格式.docx》由会员分享,可在线阅读,更多相关《Android移动终端开发大作业Word文档格式.docx(25页珍藏版)》请在冰豆网上搜索。

Android移动终端开发大作业Word文档格式.docx

信息工程

班级

信息1303

姓名

杏允升

指导教师

秦珀石

2015

12

10

1、

概述

Android应用平台新闻客户端软件是基于Android手机平台,采用Java语言,从网络上的开放的新闻接口获取数据,设计出针对使用Android平台的手机新闻客户端资讯实时掌控的手机应用程序。

Android平台新闻客户端软件的开发可以进一步扩大时事新闻的覆盖面,让广大公众能够随时随地方便且快捷地获取最新的新闻资讯信息,了解新闻时事,本软件的广泛使用,尤其是在传授知识、普及教育方面起着非常重要的作用。

目前市场研究机构Worldpanel发布了全球主要的国家智能手机操作系统在去年Q4内的分布报告,报告指出了谷歌的Android继续保持着增长的势态,但是增幅已经明显放缓了。

而在另一个方面,苹果iOS操作系统在全球只能手机市场上均有下滑,个别国家的降幅甚至高达%。

最新统计数据中显示,Android操作系统将继续领跑全球市场,包括美国、澳大利亚、中国、意大利、英国、德国、西班牙等所占的市场比例都已经超出50%,并且还将继续呈现上涨的趋势。

而在苹果iOS操作系统方面,最大的市场份额所占比的国家依旧是美国,数值为%;

紧随美国的则是澳大利亚,数值为%;

而在中国方面,市场份额也从%下降到了19%;

在意大利,iOS所占的市场份额更是从%猛降至%。

从上面的数据可以看出,Android手机软件的开发具有巨大的发展前景,在Android系统上开发出一款手机新闻客户端软件所支持的用户量也是相比较于其他系统多出很多的。

谷歌的移动平台主管安迪·

鲁宾(AndyRubin)表示,跟软件开发合作对象的密切接触正在进行中。

Google与开放手机联盟联合开发了Android操作系统,这个联盟由摩托罗拉、高通、宏达电、中国移动和T-Mobile等在内的多家无线应用和技术的领军企业组成。

Google通过与设备制造商、开发商、运营商和其他有关各方结成深层次的合作关系,希望借助建立开放式、标准化的移动移动电话软件平台,在移动产业内形成一个开放性的生态系统,这将是开发Android软件的一个契机,Android平台的开发在将来必定大放异彩。

2、

关键技术

1)使用ViewPager里面添加多张图片配合线程延时实现轮播图的自

没有通过ScheduledExecutorService或Timer定期执行某个任务实现,而是简单的通过handler发送消息去完成一次滚动,在完成一次滚动后发送另外一个delay的滚动消息,如此循环实现。

自动滚动部分核心代码如下:

至于ViewPager嵌套引起子ViewPager无法触摸问题是通过在子ViewPager的onTouchEvent中添加

禁止父控件对touchevent做intercept解决的。

ViewPager滑动速度的设置是通过反射的方式重新设置ViewPager的Scroller,改变Scroller的startScroll的间隔时间完成的。

调用setScrollDurationFactor(double)即可。

2、使用

(1)引入公共库

引入AndroidAutoScrollViewPager@Github作为你项目的library(如何拉取代码及添加公共库)。

(2)调用

仅需简单两步:

a.布局定义

代替一般的ViewPager定义

b.启动ViewPager自动滚动

startAutoScroll()启动自动滚动

stopAutoScroll()停止自动滚动

3、设置

setInterval(long)设置自动滚动的间隔时间,单位为毫秒

setDirection(int)设置自动滚动的方向,默认向右

setCycle(boolean)是否自动循环轮播,默认为true

setScrollDurationFactor(double)设置ViewPager滑动动画间隔时间的倍率,达到减慢动画或改变动画速度的效果

setStopScrollWhenTouch(boolean)当手指碰到ViewPager时是否停止自动滚动,默认为true

setSlideBorderMode(int)滑动到第一个或最后一个Item的处理方式,支持没有任何操作、轮播以及传递到父View三种模式

setBorderAnimation(boolean)设置循环滚动时滑动到从边缘滚动到下一个是否需要动画,默认为true

4、其他

(1)指示器,圆形或是方形指示器请配合ViewPagerIndicator使用

(2)无限循环,如果希望在最后一张继续播放第一张而不是退回到第一张,请参考,注意这个特性不能和ViewPagerIndicator使用

2)使用viewpager结合ViewPageIndicator进行新闻类别的分类切换,可点击切换也可以滑动切换。

1.ViewPagerIndicator的Library

查看ViewpagerIndicator的Library代码,可以看到此项目的设计思想:

首先定义了一个PageIndicator接口,它里面定义了最重要和基本的indicator表现出的一些方法:

首先一个indicator必须要与一个ViewPager关联在一起,所以它提供了一个setViewPager方法。

它扩展了接口,表示接管了ViewPager的Pager改变时的监听处理,

这也是为什么为ViewPager设置OnPageChangeListener监听器时不能设置在ViewPager上而必须设置在

indicator上的原因。

还有一个notifyDataSetChanged通知方法,表示为这个ViewPager提供View(一般是Fragment)的Adapter里面的数据集发生变化时,执行的动作,这里可增加相关的逻辑。

2.ViewpagerIndicator的实现类

然后再看下ViewpagerIndicator的实现类,共有6个,由6个类分别实现,它们分别为:

小圆圈类型的带图标类型的

小横线类型的,距离屏幕最下边端有一定的距离。

标签类型的(Tab)

标题类型的,与标签类型的有点像,但它当前的标题页的左/右边的标题会卷起,即往两端缩进去。

屏幕底部小横线类型的,并且会占满整行。

3.ViewpagerIndicator随附带的Demo

Demo项目的设计

项目由一个ListSamples的ListActivity入口,它主要用作组装所有的子indicator的列表。

,所有ViewPager上真正显示的视图。

,所有ViewPager里的Adapter,为ViewPager生成TestFragment。

,所有的indicator的显示,一个类显示一种使用方法或特性

3)使用Gson对新闻数据的json字符串进行解析显示到listview上

需要使用jar包

fastjson或gson这两个jar包。

*YoumayobtainacopyoftheLicenseat

*

*Unlessrequiredbyapplicablelaworagreedtoinwriting,software

*distributedundertheLicenseisdistributedonan"

ASIS"

BASIS,

*WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.

*SeetheLicenseforthespecificlanguagegoverningpermissionsand

*limitationsundertheLicense.

*/

publicclassTabSlidingIndicatorextendsHorizontalScrollView

{

publicinterfaceIconTabProvider

{

publicintgetPageIconResId(intposition);

}

etDisplayMetrics();

scrollOffset=(int),scrollOffset,dm);

indicatorHeight=(int),indicatorHeight,dm);

underlineHeight=(int),underlineHeight,dm);

dividerPadding=(int),dividerPadding,dm);

tabPadding=(int),tabPadding,dm);

dividerWidth=(int),dividerWidth,dm);

tabTextSize=(int),tabTextSize,dm);

etConfiguration().locale;

}

publicvoidsetViewPager(ViewPagerpager)

=pager;

if()==null){thrownewIllegalStateException("

ViewPagerdoesnothaveadapterinstance."

);

(pageListener);

notifyDataSetChanged();

publicvoidsetOnPageChangeListener(OnPageChangeListenerlistener)

=listener;

publicvoidnotifyDataSetChanged()

();

tabCount=().getCount();

for(inti=0;

i<

tabCount;

i++)

{

if()instanceofIconTabProvider)

{

addIconTab(i,((IconTabProvider)()).getPageIconResId(i));

}

else

addTextTab(i,().getPageTitle(i).toString());

updateTabStyles();

getViewTreeObserver().addOnGlobalLayoutListener(newOnGlobalLayoutListener(){

@SuppressWarnings("

deprecation"

@SuppressLint("

NewApi"

@Override

publicvoidonGlobalLayout()

{

getViewTreeObserver().removeGlobalOnLayoutListener(this);

}

else

getViewTreeObserver().removeOnGlobalLayoutListener(this);

currentPosition=();

scrollToChild(currentPosition,0);

if(pageListener!

=null)

(currentPosition);

});

privatevoidaddTextTab(finalintposition,Stringtitle)

TextViewtab=newTextView(getContext());

(title);

;

addTab(position,tab);

privatevoidaddIconTab(finalintposition,intresId)

ImageButtontab=newImageButton(getContext());

(resId);

privatevoidaddTab(finalintposition,Viewtab)

(true);

(newOnClickListener(){

publicvoidonClick(Viewv)

(position);

(tabPadding,0,tabPadding,0);

(tab,position,shouldExpandexpandedTabLayoutParams:

defaultTabLayoutParams);

privatevoidupdateTabStyles()

Viewv=(i);

(tabBackgroundResId);

if(vinstanceofTextView)

TextViewtab=(TextView)v;

tabTextSize);

(tabTypeface,tabTypefaceStyle);

oString().toUpperCase(locale));

}

privatevoidscrollToChild(intposition,intoffset)

if(tabCount==0){return;

intnewScrollX=(position).getLeft()+offset;

if(position>

0||offset>

0)

newScrollX-=scrollOffset;

if(newScrollX!

=lastScrollX)

lastScrollX=newScrollX;

scrollTo(newScrollX,0);

@Override

protectedvoidonDraw(Canvascanvas)

(canvas);

if(isInEditMode()||tabCount==0){return;

finalintheight=getHeight();

etWidth()));

invalidate();

if(delegatePageListener!

(position,positionOffset,positionOffsetPixels);

@Override

publicvoidonPageScrollStateChanged(intstate)

if(state==

scrollToChild(),0);

(state);

publicvoidonPageSelected(intposition)

updateTabStyles();

publicvoidsetIndicatorColor(intindicatorColor)

=indicatorColor;

invalidate();

publicvoidsetIndicatorColorResource(intresId)

=getResources().getColor(resId);

publicintgetIndicatorColor()

return;

publicvoidsetIndicatorHeight(intindicatorLineHeightPx)

=indicatorLineHeightPx;

publicintgetIndicatorHeight()

returnindicatorHeight;

publicvoidsetUnderlineColor(intunderlineColor)

=underlineColor;

publicvoidsetUnderlineColorResource(intresId)

publicintgetUnderlineColor()

returnunderlineColor;

publicvoidsetDividerColor(intdividerColor)

=dividerColor;

publicvoidsetDividerColorResource(intresId)

publicintgetDividerColor()

returndividerColor;

publicvoidsetUnderlineHeight(intunderlineHeightPx)

=underlineHeightPx;

publicintgetUnderlineHeight()

returnunderlineHeight;

publicvoidsetDividerPadding(intdividerPaddingPx)

=dividerPaddingPx;

publicintgetDividerPadding()

returndividerPadding;

publicvoidsetScrollOffset(intscrollOffsetPx)

=scrollOffsetPx;

publicintgetScrollOffset()

returnscrollOffset;

publicvoidsetShouldExpand(booleanshouldExpand)

=shouldExpand;

requestLayout();

publicbooleangetShouldExpand()

returnshouldExpand;

publicbooleanisTextAllCaps()

returntextAllCaps;

publicvoidsetAllCaps(booleantextAllCaps)

=textAllCaps;

publicvoidsetTextSize(inttextSizePx)

=textSizePx;

publicintgetTextSize()

returntabTextSize;

publicvoidsetTextColor(inttextColor)

=textColor;

publicvoidsetTextColor(inttextNormalColor,inttextSelectedColor)

=textNormalColor;

=textSelectedColor;

publicvoidsetTextColorResource(intresId)

publicintgetTextColor()

returntabTextColor;

publicvoidsetTypeface(Typefacetypeface,intstyle)

=

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1