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 使用ORMLite打造万能泛型Dao简化数据持久化层
  2. Android之四大布局
  3. Android布局文件属性笔记
  4. Android如何使布局中图(ImageButton)和文字(TextView)同时获得press
  5. Android数据推送实现方案
  6. Android 开发之旅:view的几种布局方式及实践
  7. Android 轻松实现语音识别的完整代码

随机推荐

  1. Android(安卓)Chronometer控件使用,计时器
  2. PopupWindow setOutsideTouchable 问题
  3. Android之解决CoordinatorLayout+AppBarL
  4. 浅谈Android(安卓)java层ServiceManager
  5. Android中插件化的简单实现:启动未注册的A
  6. android 判断ip地址合法
  7. eclipse Android开发环境配置
  8. 视频网站(网页)上获取视频源地址 详细过程
  9. AndroidStudio中gradle,buildToolsVersion
  10. [RK3288][Android6.0] 调试笔记 --- Laun