web2.0时代,twitter,follow5,新浪微博等相继火了起来,android在美国市场份额达到了13%,android market应用程序增长也越来越快,其他山寨机的market就更多了,这几个月一直在做一个微博客户端,参考其他的android微博客户端,发现有 的用webiew,做出的画面相当漂亮, 大多数的还是用android内部的控件,于是我就参照了eoe*兽*兽的tab,自己小试牛刀,帖个demo。

鄙人编程习惯先做xml,xml定义如下,一个frameLayout,里面嵌套了四个LinearLayout,如下

<?xml version="1.0" encoding="utf-8"?><FrameLayout android:id="@+id/FrameLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"><LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/first"></LinearLayout><LinearLayout android:id="@+id/fourth" android:layout_width="wrap_content" android:layout_height="wrap_content"></LinearLayout><LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/second"></LinearLayout><LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/third"></LinearLayout></FrameLayout>

布局文件可以自己根据需要调整,这里我就不多说。

好了,布局完毕,添加java代码,这里我要用网络上的资源,用listview显示出来,这里我首先想到了follow5,

follow5是国内不错的一个微博,api开放使用,不过要先取得一个apikey才可以进行开发,具体请参考http://www.follow5.com/f5/jsp/other/api

/api.jsp

获得apikey之后,为了简单起见,先使用follow5的最新分享,不需要用户名和密码 api如下:

http://api.follow5.com/api/statuses/public_timeline.xml? api_key=****

这样,你就可以获得一大串xml文件,这里你可以用xml解析器来解析,解析完成后,把获得数据放到arraylist里面备用,对于xml解析, 大家一定不陌生,在android里面一般可以使用sax或者xmlpullparser来解析,用dom估计不太现实,太占资源了,对于sax和 xmlpullparser解析,可以看以下介绍:

http://www.iteye.com/topic/41564

http://www.iteye.com/topic/401377

高手阿,自己学习学习......

好了,关键部分来了,我们要把数据放入listiew里面了,譬如我们获得的数据放在

ArrayList<Map<String, Object>> data里面,listview显示内容,listview内部布局自己定义好了,

代码如下:

SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.list_item_time_line,                new String[] {UserInfo.SCREENNAME, TimeLineInfo.STATUS, UserInfo.USER_IMAGE,TimeLineInfo.TIME},                new int[] { R.id.screen_name, R.id.status, R.id.user_image, R.id.update_time});

然后对放入的数据进行格式操作,

adapter.setViewBinder(new MyImageBinder(context));

其中MyImageBinder重写ViewBinder,对ArrayList里面的文字和图片进行操作,具体细节见代码

代码下载地址:

http://www.anhuioss.com/download/android/crowdroid/Crowdroid1.1.0_source.zip

国内微博起步晚,但是发展势头强劲,虽然饭否等其他的微博由于一些原因没有开服,但新浪、

follow5依然做得有声有色,希望国内微博提供统一的api,这样即方便了开发者,也让公司的产品

更容易推广。

更多相关文章

  1. android全平台编译ffmpeg以及x264与fdk-aac实践
  2. Android的init过程(二):初始化语言(init.rc)解析
  3. execlp启动android进程命令窗口通过adb shell 进入android 的Lin
  4. Android读写XML(上)——package说明
  5. Android高手进阶教程(四)之----Android(安卓)中自定义属性(attr.
  6. android 图片解码显示流程
  7. Google Android操作系统内核编译图文教程
  8. Android(安卓)关机解析
  9. 关于android中的gif实现

随机推荐

  1. Android API版本对应Android系统版本及内
  2. Android C/C++开发指南
  3. Android入门教程 (一) Android简介和androi
  4. 4.0.x Launcher UI
  5. [原]如何在Android用FFmpeg+SDL2.0解码图
  6. android:ellipsize属性 textview
  7. Android异步消息处理机制
  8. Android键盘系统
  9. RelativeLayout的对齐属性大全(LinearLayo
  10. Android设置item的行间距,以及去掉分割线